在IF语句[BATCH]之后,Goto目前无法预料

时间:2019-05-06 02:24:53

标签: batch-file

我正在批量编程一个非常基本的基于文​​本的游戏,并且我试图为整个游戏中的文本设置滚动速度。这是给我带来问题的代码摘录。

:TextSpeed
cls
Echo Please select a Text Speed:
echo A) Instant
echo B) Fast
echo C) Slow
SET /P TextSpeedSelection= Select a text speed:
IF %TextSpeedSelection% == A goto SpeedA
IF %TextSpeedSelection% == B goto SpeedB
IF %TextSpeedSelection% == C goto SpeedC

:SpeedA
::The fastest speed, which is simply the echo command
echo %TextSpeedSelection%
SET TextSpeed = 1
echo Is this speed okay?
SET /P %ConfirmTextSpeed%=Y/N?
IF %ConfirmTextSpeed% == Y goto Create
IF %ConfirmTextSpeed% == N goto TextSpeed

:SpeedB
echo %TextSpeedSelection%
SET TextSpeed = 2
set string=Is this speed okay?

for /L %%a in (1, 1, 19) do (
set string2=!string:~0,%%a!
cls
echo !string2!
ping localhost -n 1 >nul
if %%a GEQ 19 goto eof
)
:eof
SET /P %ConfirmTextSpeed%=Y/N?
IF %ConfirmTextSpeed% == Y goto Create
IF %ConfirmTextSpeed% == N goto TextSpeed

:SpeedC
echo %TextSpeedSelection%
SET TextSpeed = 3
set string=Is this speed okay?

for /L %%a in (1, 1, 19) do (
set string2=!string:~0,%%a!
cls
echo !string2!
ping localhost -n 1 >nul
if %%a GEQ 19 goto eof
)
:eof
SET /P %ConfirmTextSpeed%= Y/N? :
IF %ConfirmTextSpeed% == Y goto Create
IF %ConfirmTextSpeed% == N goto TextSpeed

一旦代码点击“ goto Create”或“ goto TextSpeed”部分,它会关闭命令提示符窗口,并显示错误信息“ Goto当时是意外的”。理想情况下,此代码应继续执行而不会崩溃。

0 个答案:

没有答案