China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-07-06 17:11
中国DOS联盟论坛 » DOS学习入门 & 精彩文章 (教学室) » Problems with PING View 2,167 Replies 19
Floor 16 Posted 2007-03-12 07:02 ·  中国 江苏 南京 电信
初级用户
Credits 76
Posts 39
Joined 2007-03-09 06:54
19-year member
UID 81169
Gender Male
Status Offline
For count-1, if count=%count%-1, then it is 10-1
1: What is the difference between global and local for the environment variables defined by set?
2: Can the environment variable string contain any symbols?
set %count%=count-1 is set 10=count-1
Here, is 10 a variable? The result of echo %10% is echo 0. I don't understand 0 here.....

Note:
Display, set, or delete environment variables. If there are no parameters, the set command will display the current environment settings.

Syntax
set ] ] string]

Parameters
/a
Set string to an evaluable numeric expression.
/p
Set the value of variable to an input line.
variable
Specifies the variable to be set or modified.
string
Specifies the string to be associated with the specified variable.
/?
Displays help at the command prompt.
狐狸喜欢狡猾。。
Floor 17 Posted 2007-03-12 07:18 ·  中国 江苏 南京 电信
初级用户
Credits 76
Posts 39
Joined 2007-03-09 06:54
19-year member
UID 81169
Gender Male
Status Offline
10 is a variable but %10% is ambiguous... So how to improve it???? Can the variable defined by set contain an = sign? How to do it??
狐狸喜欢狡猾。。
Floor 18 Posted 2007-03-12 07:19 ·  中国 江苏 南京 电信
初级用户
Credits 76
Posts 39
Joined 2007-03-09 06:54
19-year member
UID 81169
Gender Male
Status Offline
What are the points to pay attention to when using the %???????????????
狐狸喜欢狡猾。。
Floor 19 Posted 2007-03-16 00:25 ·  中国 浙江 杭州 电信
银牌会员
★★★
Credits 2,000
Posts 621
Joined 2007-01-01 00:00
19-year member
UID 75212
Gender Male
Status Offline
Floor 20 Posted 2007-03-16 00:38 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline

  Re hxmupdata:

  Regarding the usage of set: If set is used without the /a parameter, it means direct assignment, that is, the value after the = sign is directly assigned to the variable before the = sign. If you want to use set for simple arithmetic operations, you must add the /a parameter because the /a parameter specifies that set is for arithmetic operations. For example, set a=1+7, then the value of variable a is "1+7". Adding the /a parameter can calculate the arithmetic expression after the = sign. For example, set /a a=1+7, then the value of variable a is 8. If you want to reference this variable, you need to enclose the variable a with %, for example, echo %a%, so that the value of variable a can be displayed.

  In addition, there can be "=" signs in variables. For example, set str=a=b=c, then the result of echo %str% is "a=b=c".
Forum Jump: