我正在尝试制作一个基于批处理文本的游戏。但刚开始写就遇到了以前从未遇到过的问题。
:menu
:: the game menu - opens when the game starts
cls
echo This game is still being made -- expermintal
echo Start Screen:
echo [1] View Changes
echo [2] Start Game
echo enter your choice:
set /p startchoice =
if %startchoice%==1 goto changes
if %startchoice%==2 goto startgame
当我输入 1 或 2 时,它显示错误“此时 goto 是意外的”我该如何修复它?
Your startchoice
设置不正确。使用替代语法set /p
您在那里提供提示(并删除之间的空格startchoice
和作业(=
) 运算符 - 我认为这实际上是问题的原因,但是如果您使用set /p <variable>=<Prompt>
句法)。
我添加了两个目标goto
, and echo
声明,以便您可以看到它们已达成:
:menu
:: the game menu - opens when the game starts
cls
echo This game is still being made -- expermintal
echo Start Screen:
echo [1] View Changes
echo [2] Start Game
set /p startchoice=Enter your choice:
if %startchoice%==1 goto changes
if %startchoice%==2 goto startgame
:changes
echo Changes
goto end
:startgame
echo StartGame
:end
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)