我正在尝试创建一个有趣的炸弹病毒,该病毒会闪烁一堆带有一组文本的窗口,然后经过一定次数的迭代后会闪烁一堆带有一组单独的文本的窗口,来回移动。我无法从一组文本切换到另一组文本。它只是一直停留在一个集合上。这是我到目前为止所得到的。
start 123.bat
echo off
set /a count=1
set /a coun=1
:first
timeout /t 1
echo FOLLOW THIS FOLLOW THIS FOLLOW THIS FOLLOW THIS FOLLOW THIS FOLLOW THIS
echo FOLLOW THIS FOLLOW THIS FOLLOW THIS FOLLOW THIS FOLLOW THIS FOLLOW THIS
echo FOLLOW THIS FOLLOW THIS FOLLOW THIS FOLLOW THIS FOLLOW THIS FOLLOW THIS
echo FOLLOW THIS FOLLOW THIS FOLLOW THIS FOLLOW THIS FOLLOW THIS FOLLOW THIS
echo FOLLOW THIS FOLLOW THIS FOLLOW THIS FOLLOW THIS FOLLOW THIS FOLLOW THIS
echo FOLLOW THIS FOLLOW THIS FOLLOW THIS FOLLOW THIS FOLLOW THIS FOLLOW THIS
echo FOLLOW THIS FOLLOW THIS FOLLOW THIS FOLLOW THIS FOLLOW THIS FOLLOW THIS
echo FOLLOW THIS FOLLOW THIS FOLLOW THIS FOLLOW THIS FOLLOW THIS FOLLOW THIS
echo FOLLOW THIS FOLLOW THIS FOLLOW THIS FOLLOW THIS FOLLOW THIS FOLLOW THIS
echo FOLLOW THIS FOLLOW THIS FOLLOW THIS FOLLOW THIS FOLLOW THIS FOLLOW THIS
echo FOLLOW THIS FOLLOW THIS FOLLOW THIS FOLLOW THIS FOLLOW THIS FOLLOW THIS
echo FOLLOW THIS FOLLOW THIS FOLLOW THIS FOLLOW THIS FOLLOW THIS FOLLOW THIS
set /a count=%count%+1
if %count%==25 (goto next)
goto first
:next
timeout /t 1
echo THEN GET YOUR EYES CHECKED THEN GET YOUR EYES CHECKED THEN GET YOUR EYES CHECKED
echo THEN GET YOUR EYES CHECKED THEN GET YOUR EYES CHECKED THEN GET YOUR EYES CHECKED
echo THEN GET YOUR EYES CHECKED THEN GET YOUR EYES CHECKED THEN GET YOUR EYES CHECKED
echo THEN GET YOUR EYES CHECKED THEN GET YOUR EYES CHECKED THEN GET YOUR EYES CHECKED
echo THEN GET YOUR EYES CHECKED THEN GET YOUR EYES CHECKED THEN GET YOUR EYES CHECKED
echo THEN GET YOUR EYES CHECKED THEN GET YOUR EYES CHECKED THEN GET YOUR EYES CHECKED
echo THEN GET YOUR EYES CHECKED THEN GET YOUR EYES CHECKED THEN GET YOUR EYES CHECKED
echo THEN GET YOUR EYES CHECKED THEN GET YOUR EYES CHECKED THEN GET YOUR EYES CHECKED
echo THEN GET YOUR EYES CHECKED THEN GET YOUR EYES CHECKED THEN GET YOUR EYES CHECKED
echo THEN GET YOUR EYES CHECKED THEN GET YOUR EYES CHECKED THEN GET YOUR EYES CHECKED
echo THEN GET YOUR EYES CHECKED THEN GET YOUR EYES CHECKED THEN GET YOUR EYES CHECKED
echo THEN GET YOUR EYES CHECKED THEN GET YOUR EYES CHECKED THEN GET YOUR EYES CHECKED
set /a coun=%coun%+1
if %coun%==25 (goto first)
goto next
在此工作上的任何帮助将不胜感激。
答案 0 :(得分:0)
问题是count
和coun
变量应在每次执行命令块时每次初始化为1
,也就是说,您可以插入一个附加标签,例如:first0
,并将set count=1
放在其下方(在其下方带有:first
标签),并修复相应的 goto first
命令。 :next
标签和coun
变量也是如此。顺便说一句,以这种方式,不再需要在两个循环中使用不同的变量...
但是,使用for /L
命令更简单:
@echo off
:first
for /L %%f in (1,1,25) do (
timeout /t 1
for /L %%i in (1,1,12) do echo FOLLOW THIS FOLLOW THIS FOLLOW THIS FOLLOW THIS FOLLOW THIS FOLLOW THIS
)
:next
for /L %%n in (1,1,25) do (
timeout /t 1
for /L %%i in (1,1,12) do echo THEN GET YOUR EYES CHECKED THEN GET YOUR EYES CHECKED THEN GET YOUR EYES CHECKED
)
goto first
您还可以使用for /L
命令创建没有循环值的无限循环:
@echo off
for /L %%x in () do (
for /L %%f in (1,1,25) do (
timeout /t 1
for /L %%i in (1,1,12) do echo FOLLOW THIS FOLLOW THIS FOLLOW THIS FOLLOW THIS FOLLOW THIS FOLLOW THIS
)
for /L %%n in (1,1,25) do (
timeout /t 1
for /L %%i in (1,1,12) do echo THEN GET YOUR EYES CHECKED THEN GET YOUR EYES CHECKED THEN GET YOUR EYES CHECKED
)
)