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-08-04 18:30
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Question about 0+0 View 720 Replies 2
Original Poster Posted 2007-05-22 16:28 ·  中国 河北 秦皇岛 电信
初级用户
Credits 68
Posts 32
Joined 2007-04-01 12:12
19-year member
UID 83621
Gender Male
Status Offline
Inside a for loop, like for /l %c in (0,0,0) do echo %c, why does it become an endless loop? Shouldn't it be the same as for /l %c in (1,1,1) do echo %c?
Floor 2 Posted 2007-05-22 19:36 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
20-year member
UID 59080
Status Offline
Because the increment in this for is 0, which means after each loop, the result is still the initial value 0, so it keeps looping.

And with (1,1,1), after one loop it becomes 2, which is greater than the 1 at the end, so it only loops once.

for /l %a in (1,0,1) do @echo %a is also an infinite loop.
Floor 3 Posted 2007-05-25 10:25 ·  中国 河北 秦皇岛 电信
初级用户
Credits 68
Posts 32
Joined 2007-04-01 12:12
19-year member
UID 83621
Gender Male
Status Offline
Got it! Thanks, lxmxn moderator
Forum Jump: