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-06-20 06:08
中国DOS联盟论坛 » DOS疑难解答 & 问题讨论 (解答室) » Please clarify the specific content related to the "FOR statement / the secret" you want to express, as the current description is too vague. For example, is it about the syntax of the FOR statement in a certain programming language and the meaning of the "/" in it, or something else? Please provide more detailed information. View 3,589 Replies 25
Original Poster Posted 2006-10-24 07:22 ·  中国 江西 南昌 联通
新手上路
Credits 6
Posts 2
Joined 2006-10-20 23:29
19-year member
UID 67361
Status Offline
I'm a student who has just started learning DOS language.
I'm very interested when learning.
But when I learned the FOR statement, I had a problem.
That is, what do the three parameters /R, /L, and /F mean respectively? Are there any other parameters?
I checked some materials for this problem and only found simple explanations. I hope an expert can tell me a more detailed explanation. Thanks here again.:D
Floor 2 Posted 2006-10-24 07:35 ·  中国 上海 松江区 电信
铂金会员
★★★★
DOS一根葱
Credits 5,493
Posts 2,315
Joined 2006-05-01 10:41
20-year member
UID 54766
Gender Male
From 上海
Status Offline
FOR /? is all its help! But the FOR command is not easy to master哦. Flexibility in application and thinking are very important. Search more examples on the forum to have a look~
第一高手 第二高手

Floor 3 Posted 2006-10-24 08:07 ·  中国 江西 南昌 联通
新手上路
Credits 6
Posts 2
Joined 2006-10-20 23:29
19-year member
UID 67361
Status Offline
Originally posted by fastslz at 2006-10-24 07:35:
FOR /? is all its help! But the FOR command is not easy to master! Flexible application, and ideas are important. Search more examples in the forum to see~

FOR /? I have seen it come over`````But only FOR /R and FOR /F explanation`````
That /L are I see in the example````
I don't know other / behind the parameters of FOR`````In this case, flexible application do not talk about`````
Floor 4 Posted 2006-10-24 08:30 ·  中国 广东 佛山 广东睿江科技有限公司
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
Please click here: The Most Powerful DOS Command – for

[ Last edited by namejm on 2006-10-24 at 09:36 AM ]
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Floor 5 Posted 2006-10-24 08:34 ·  中国 陕西 西安 电信
新手上路
Credits 14
Posts 7
Joined 2006-10-20 11:48
19-year member
UID 67270
Status Offline
I know nothing, just come here to learn~~~
Floor 6 Posted 2006-10-24 09:06 ·  中国 甘肃 甘南藏族自治州 合作市 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
The help for for is also very good, ah
Floor 7 Posted 2006-10-24 10:44 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline

Actually, the /L parameter is in the help for for. It's just that for novice friends, the explanation is relatively obscure. If you search in the forum, there are many usages of the for command.

Personally, I feel that to learn anything, you first need to learn how to study. Once you master a good learning method, you can learn everything smoothly. That's the most important thing.
Floor 8 Posted 2006-10-25 04:27 ·  中国 湖北 襄阳 电信
新手上路
Credits 4
Posts 1
Joined 2006-10-24 23:33
19-year member
UID 68108
Gender Male
From 湖北省襄樊市
Status Offline
I don't understand very well either: for /l is a loop...
For example: for /l %i in (1,1,1000) echo %i will display: 1 to 1000 1 is the start value, the second 1 is the increase value, if it is -1 it is the decrease value, 1000 is the end value.
I don't know if what I said is right.
First time coming to the DOS Union Bar to report... Please give your guidance,各位 masters...
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
redtek +2 2006-10-25 10:48
Floor 9 Posted 2006-10-25 09:47 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline
Originally posted by flyskygen at 2006-10-25 04:27:
I don't understand very well either: for /l is a loop...
For example: for /l %i in (1,1,1000) echo %i will display: 1 to 1000. 1 is the start value, the second 1 is the increase value. If it is -1, it is the decrease value. 1000...


  That's quite good.

The meaning of for /l %i in (100,-2,60) do @echo %i is to sequentially display the number sequence on the screen: 100, 98, 96, 94,..., 62, 60. The three actual parameters in () are respectively the starting value, the step size (that is, the increase amount each time), and the last parameter is the end value, meaning that %i stops when it reaches 60.

Another example:
for /l %a in (1,1,255) do @net view 192.168.1.%a
You can view the shared resource lists of machines with IPs from 192.168.1.1 to 192.168.1.255 in the local area network.
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
redtek +4 2006-10-25 10:45
Floor 10 Posted 2006-10-25 23:58 ·  中国 河南 南阳 中移铁通
初级用户
Credits 122
Posts 12
Joined 2004-04-24 00:00
22-year member
UID 23125
Gender Male
Status Offline
The example above is very easy to understand. It's no different from VB, and even simpler. Just the one at the back, what does %a mean? in (1,1,255) do @net view 192.168.1. 1,1,255. Does it mean starting from 192.168.1.1, incrementing by one each time, and then exhaustively enumerating up to 255?

[ Last edited by ghtfuo on 2006-10-26 at 12:04 AM ]
Floor 11 Posted 2006-10-26 00:01 ·  中国 河南 南阳 中移铁通
初级用户
Credits 122
Posts 12
Joined 2004-04-24 00:00
22-year member
UID 23125
Gender Male
Status Offline
Are there also many syntax formats for statements like net view?
Floor 12 Posted 2006-10-26 00:53 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline
Originally posted by ghtfuo at 2006-10-26 00:01:
Statements similar to net view
Are there also many syntax formats?


  Re:ghtfuo

    In the command "for /l %a in (1,1,255) do @net view 192.168.1.%a" I mentioned above, %a is a variable. The specific value of this variable is the sequence of numbers from 1 to 255 represented by (1,1,255) in the parentheses (). This command means to execute 255 times. And the value of variable %a will increase by 1 each time the for is executed once, which is the step size (that is, the growth amount) I mentioned above. So the value of variable %a is 1, 2, 3, ……, 255, and then it increases to 255 in turn. When it reaches 255 (the end value), it will not execute, and the execution of this for command will terminate. After using this for command, %a represents these number sequences. So "net view 192.168.1.%a" means to execute "net view 192.168.1.1", "net view 192.168.1.2", "net view 192.168.1.3", ……, "net view 192.168.1.255".

    As for the syntax of net view, there are actually not many. The specific syntax can be viewed by using the "net help view" command to view its command-line help information.


[ Last edited by lxmxn on 2006-10-26 at 12:55 AM ]
Floor 13 Posted 2006-10-26 01:03 ·  中国 河南 南阳 中移铁通
初级用户
Credits 122
Posts 12
Joined 2004-04-24 00:00
22-year member
UID 23125
Gender Male
Status Offline
Thanks.

%a refers to each number obtained by increasing by a step size, that is, the set of numbers in the subsequent (1, 1, 255) result, right?

Can we use %b %c %d?

Don't mind me being too inquisitive :D
Floor 14 Posted 2006-10-26 01:04 ·  中国 河南 南阳 中移铁通
初级用户
Credits 122
Posts 12
Joined 2004-04-24 00:00
22-year member
UID 23125
Gender Male
Status Offline
Floor 15 Posted 2006-10-26 01:36 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline
Originally posted by ghtfuo at 2006-10-26 01:04:
Got it......

 
  Re: ghtfuo

    I'm glad you got it. Because mastering the for command is a relatively difficult hurdle for friends who are just getting started with batch processing.

    In addition, a supplement:
  When executing the for command in the command prompt, variables are generally represented by one %, for example, using %a, %b, %i is all right. But when executing the for command in a batch processing, two %% are needed, for example, using %%i, %%a, %%p, etc. Also, variables are case-sensitive, for example, %%a and %%A are two different variables.


[ Last edited by lxmxn on 2006-10-26 at 01:39 AM ]
Forum Jump: