中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-04 17:19
48,038 topics / 350,123 posts / today 0 new / 48,251 members
DOS批处理 & 脚本技术(批处理室) » Question about 0+0
Printable Version  718 / 2
Floor1 guxingyibei Posted 2007-05-22 16:28
初级用户 Posts 32 Credits 68
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?
Floor2 lxmxn Posted 2007-05-22 19:36
版主 Posts 4,938 Credits 11,386
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.
Floor3 guxingyibei Posted 2007-05-25 10:25
初级用户 Posts 32 Credits 68
Got it! Thanks, lxmxn moderator
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023