|
doyoukissme
新手上路

积分 6
发帖 2
注册 2006-10-20
状态 离线
|
『楼 主』:
请问FOR语句 /的秘密`````
使用 LLM 解释/回答一下
我是个刚学DOS语言的学生```
在学习时很有兴趣```
可在学到FOR语句的时候出现了个问题`````
就是FOR /R
/L
/F
这3个参数个是什么意思```是不是还有其他的参数```
我这问题``查了些资料就发现了简单的解说````希望有高手能好告诉我比较详细的解说 ````在次谢过了```:D
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
|
|
2006-10-24 07:22 |
|
|
fastslz
铂金会员
       DOS一根葱
积分 5493
发帖 2315
注册 2006-5-1 来自 上海
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
FOR /? 就是它的全部帮助呀!但是FOR命令不容易掌握哦,灵活应用、及思路很重要。在论坛上多搜索些实例看看~
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~
|

第一高手 第二高手
我的小站
 |
|
2006-10-24 07:35 |
|
|
doyoukissme
新手上路

积分 6
发帖 2
注册 2006-10-20
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
Originally posted by fastslz at 2006-10-24 07:35:
FOR /? 就是它的全部帮助呀!但是FOR命令不容易掌握哦,灵活应用、及思路很重要。在论坛上多搜索些实例看看~
FOR /?我已经看过来`````可是里面只有FOR /R 和FOR /F的解说````
那个/L的都是我在实例中看到的`````
我根本不知道FOR里面其他的/后面的参数``这样的话灵活应用就不要谈了``
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`````
|
|
2006-10-24 08:07 |
|
|
namejm
荣誉版主
       batch fan
积分 5226
发帖 1737
注册 2006-3-10 来自 成都
状态 离线
|
|
2006-10-24 08:30 |
|
|
jinstar211
新手上路

积分 14
发帖 7
注册 2006-10-20
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
我社么也不懂,来这学习下~~~
I know nothing, just come here to learn~~~
|
|
2006-10-24 08:34 |
|
|
vkill
金牌会员
     
积分 4103
发帖 1744
注册 2006-1-20 来自 甘肃.临泽
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
for 的帮助也很好的 啊
The help for for is also very good, ah
|
|
2006-10-24 09:06 |
|
|
lxmxn
版主
       
积分 11386
发帖 4938
注册 2006-7-23
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
其实for的帮助里面有/L参数的,只是对于新手朋友来说,讲解得比较晦涩难懂,在论坛里面搜索一下就有很多的关于for命令的用法的。
个人感觉要学什么东西,首先要学会怎么去学习,掌握了好的学习方法,学什么都能很顺利的。这才是最重要的。
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.
|
|
2006-10-24 10:44 |
|
|
flyskygen
新手上路

积分 4
发帖 1
注册 2006-10-24 来自 湖北省襄樊市
状态 离线
|
『第 8 楼』:
使用 LLM 解释/回答一下
我也不咋的懂:for /l 是个循环的……
比如: for /l %i in (1,1,1000) echo %i 会显示:1 到1000 1就是开始值,第二个1是增加值,如果是-1就是减少的值,1000就是结束值。
不知道说的对不对
初次来DOS盟吧报到……请各位高手指教……
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...
|
|
2006-10-25 04:27 |
|
|
lxmxn
版主
       
积分 11386
发帖 4938
注册 2006-7-23
状态 离线
|
 『第 9 楼』:
使用 LLM 解释/回答一下
Originally posted by flyskygen at 2006-10-25 04:27:
我也不咋的懂:for /l 是个循环的……
比如: for /l %i in (1,1,1000) echo %i 会显示:1 到1000 1就是开始值,第二个1是增加值,如果是-1就是减少的值,1000尠...
说得不错。
for /l %i in (100,-2,60) do @echo %i
的意思就是依次显示在屏幕下显示数字序列:100,98,96,94,……,62,60,其中()中的三个实参分别是起点值,步长(也就是每次的增加量),最后一个参数是结束值,指%i到了60就停止。
再举个例子:
for /l %a in (1,1,255) do @net view 192.168.1.%a
可以查看局域网中IP为192.168.1.1--192.168.1.255的机器的共享资源列表。
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.
|
|
2006-10-25 09:47 |
|
|
ghtfuo
初级用户
 
积分 122
发帖 12
注册 2004-4-24
状态 离线
|
『第 10 楼』:
使用 LLM 解释/回答一下
上面的例子第一个很好理解
跟VB没区别
甚至更简单
只是后面的那个
%a是什么意思
in (1,1,255) do @net view 192.168.1.
1,1,255
是不是从192.168.1.1开始每进阶一个数字
然后一直穷举到255?
Last edited by ghtfuo on 2006-10-26 at 12:04 AM ]
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 ]
|
|
2006-10-25 23:58 |
|
|
ghtfuo
初级用户
 
积分 122
发帖 12
注册 2004-4-24
状态 离线
|
『第 11 楼』:
使用 LLM 解释/回答一下
类似net view这种语句
是不是也有很多语法格式?
Are there also many syntax formats for statements like net view?
|
|
2006-10-26 00:01 |
|
|
lxmxn
版主
       
积分 11386
发帖 4938
注册 2006-7-23
状态 离线
|
『第 12 楼』:
使用 LLM 解释/回答一下
Originally posted by ghtfuo at 2006-10-26 00:01:
类似net view这种语句
是不是也有很多语法格式?
Re:ghtfuo
在我上面举的这个命令"for /l %a in (1,1,255) do @net view 192.168.1.%a"中,%a是一个变量,这个变量的具体值,就是括号()中(1,1,255)所代表的1到255的数字序列,这个命令就是执行255次的意思,而变量%a的值会随着for的执行一次而增加一次,就会增加1,也就是我上面所说的步长(就是增长量)了,所以变量%a的值是1,2,3,……,255,这样就依次的增加到255,到了255(结束值)就不执行了,这个for命令的执行也就终止了。当用了这个for命令之后,%a就代表这些数字序列,所以"net view 192.168.1.%a"就表示执行"net view 192.168.1.1"、"net view 192.168.1.2"、"net view 192.168.1.3"、……、"net view 192.168.1。255"了。
至于net view的语法,其实不是很多,具体的语法可以用"net help view"命令查看其命令行帮助信息。
Last edited by lxmxn on 2006-10-26 at 12:55 AM ]
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 ]
|
|
2006-10-26 00:53 |
|
|
ghtfuo
初级用户
 
积分 122
发帖 12
注册 2004-4-24
状态 离线
|
『第 13 楼』:
使用 LLM 解释/回答一下
谢谢了
%a 是指代每一个递增一个步长所取得的数字,也就是后面 (1,1,255)结果的数字集合
是吧
可不可以用%b %c %d
呢
不要在意我打破砂锅问到底啊:D
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
|
|
2006-10-26 01:03 |
|
|
ghtfuo
初级用户
 
积分 122
发帖 12
注册 2004-4-24
状态 离线
|
|
2006-10-26 01:04 |
|
|
lxmxn
版主
       
积分 11386
发帖 4938
注册 2006-7-23
状态 离线
|
『第 15 楼』:
使用 LLM 解释/回答一下
Originally posted by ghtfuo at 2006-10-26 01:04:
明白了……
Re:ghtfuo
对于你明白了感到欣慰,因为for命令的掌握对于刚接触批处理的朋友来说,都是比较难过的一关。
另外,补充一下:
在命令提示符中执行for命令的时候,变量一般用一个%,比如用%a,%b,%i都可以,但是在批处理中执行for命令时,就要用两个%%,比如用%%i,%%a,%%p等,而且变量是区分大小写的,比如%%a与%%A是两个不同的变量。
Last edited by lxmxn on 2006-10-26 at 01:39 AM ]
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 ]
|
|
2006-10-26 01:36 |
|