我为我的批处理游戏开发了一项新功能,该功能使用户能够定义自己的保存文件的名称以及加载系统,并且新的保存系统现在运行正常。
然而,在测试新代码期间,程序会给出一条消息“命令的语法不正确。”并且崩溃。
:load2
cls
color E
echo Warning: Spaces not allowed!
set /p load2=File:
set ext1=.sav
set ext2=.bat
cls
echo Loading Save File...
ping localhost -n 1 >nul
if exist %load2%%ext1%
if not exist %load2%%ext1% goto :nosave
ping localhost -n 2 >nul
ren %load2%%ext1% %load2%%ext2%
call %load2%%ext2%
ren %load2%%ext2% %load2%%ext1%
cls
color A
echo Game loaded.
ping localhost -n 2 >nul
cls
if %saver%=player1 goto :p1sturn
if %saver%=player2 goto :p2sturn
感谢您的阅读,所有参与的人都会被添加到帮助我完成 cod 的信用中
答案1
==>if exist x
The syntax of the command is incorrect.
导致的错误if exist %load2%%ext1%
。将其完全删除:它是多余的,后面跟着if not exist %load2%%ext1% goto :nosave
另一个错误:
==>if player1=player1 echo x
=player1 was unexpected at this time.
正确的语法(注意引号和双=
等号):
if "%saver%"=="player1" goto :p1sturn
if "%saver%"=="player2" goto :p2sturn