I'm programming a really basic text based game in batch, and I'm attempting to set a scrolling speed for the text throughout the game. Heres the extract of code thats giving me issues.

: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

Once the code hits the "goto Create" or "goto TextSpeed" part, it closes the command prompt window, and gives me and error which says "Goto was unexpected at this time". Ideally this code should continue on without crashing like it does.

0 Answers