我为不能在 Win32 上运行的游戏编写了一个用于遗留 DOS 系统的批处理文件。该代码在 XP x86 下运行良好,但是当我在 98SE 或 DOS 中运行它时,在第一次提示后出现语法错误。由于 goto,文件运行到一个循环中。我该如何解决?
源代码:
@echo off
:PROMPT
cls
echo.
echo Welcome to the Game Selection Wizard!
echo --------------------------------------
echo.
echo Please Select a Game:
echo.
echo 1. Game1
echo 2. Game2
echo 3. Return To MS-DOS
echo.
set /p GAME= Your Current Selection:
if %game%==1 goto Game1
if %game%==1. goto Game1
if %game%==2 goto Game2
if %game%==2. goto Game2
if %game%==3 goto QUIT
if %game%==3. goto QUIT
goto INVALID
:INVALID
cls
echo.
echo * * * * * * * * * * * * * * * * * * * * * * * * * * *
echo * *
echo * ERROR: *
echo * ------ *
echo * The choice you selected is wrong. Try Again! *
echo * *
echo * * * * * * * * * * * * * * * * * * * * * * * * * * *
echo.
echo Welcome to the Game Selection Wizard!
echo -------------------------------------
echo.
echo Please Select a Game:
echo.
echo 1. Game1
echo 2. Game2
echo 3. Return To MS-DOS
echo.
set /p gameerror= Your Current Selection:
if %gameerror%==1 goto Game1
if %gameerror%==1. goto Game1
if %gameerror%==2 goto Game2
if %gameerror%==2. goto Game2
if %gameerror%==3 goto QUIT
if %gameerror%==3. goto QUIT
cls
goto INVALID
:Game1
cls
call A:\GAMES\Game1.exe
goto PROMPT
:Game2
cls
call A:\GAMES\Game2.exe
goto PROMPT
:QUIT
cls
echo.
echo Are you sure you want to return to MS-DOS?
echo.
set /p quit= Confirmation:
if %quit%==y goto DIE
if %quit%==Y goto DIE
if %quit%==yes goto DIE
if %quit%==Yes goto DIE
if %quit%==YES goto DIE
if %quit%==n goto PROMPT
if %quit%==N goto PROMPT
if %quit%==no goto PROMPT
if %quit%==No goto PROMPT
if %quit%==NO goto PROMPT
goto QUITERROR
:QUITERROR
cls
echo * * * * * * * * * * * * * * * * * * * * * * * * * * *
echo * *
echo * ERROR: *
echo * ------ *
echo * The choice you selected is wrong. Try Again! *
echo * *
echo * * * * * * * * * * * * * * * * * * * * * * * * * * *
echo.
echo Are you sure you want to return to MS-DOS?
echo.
set /p quiterror= Confirmation:
if %quiterror%==y goto DIE
if %quiterror%==Y goto DIE
if %quiterror%==yes goto DIE
if %quiterror%==Yes goto DIE
if %quiterror%==YES goto DIE
if %quiterror%==n goto PROMPT
if %quiterror%==N goto PROMPT
if %quiterror%==no goto PROMPT
if %quiterror%==No goto PROMPT
if %quiterror%==NO goto PROMPT
goto QUITERROR
:DIE
cls
echo.
echo Returning to MS-DOS...