我试图找出当我打开文件时我的文件立即退出的原因。
我试图猜数字游戏。
@echo off
set morl="Between 1 and 100"
:menu
cls
echo 1) Start
echo 2) Instructions
set /p option=
if %option%==1 goto loop
if %option%==2 goto instructions
goto error
:error
cls
echo Enter 1 or 2
pause
goto menu
:instructions
cls
echo 1. Enter a number
echo 2. It will say higher or lower
echo 3. Repeat based on step 2
pause
:loop
cls
echo Loading...
set num=%random%
if /i %num% GTR 10 goto loop
if /i %num% LSS 1 goto loop
goto start
:start
cls
echo The answer is %morl%
set /p input=
if %input%==%num% goto win
if %input% lss %num% set morl="higher"
if %input% gtr %num% set morl="lower"
goto start
:win
cls
echo You won! the answer was %num%
pause
goto menu
答案 0 :(得分:1)
你需要调用菜单功能
@echo off
set morl="Between 1 and 100"
goto menu
:menu
cls
echo 1) Start
echo 2) Instructions
set /p option=
if %option%==1 goto loop
if %option%==2 goto instructions
goto error
:error
cls
echo Enter 1 or 2
pause
goto menu
:instructions
cls
echo 1. Enter a number
echo 2. It will say higher or lower
echo 3. Repeat based on step 2
pause
:loop
cls
echo Loading...
set num=%random%
if /i %num% GTR 10 goto loop
if /i %num% LSS 1 goto loop
goto start
:start
cls
echo The answer is %morl%
set /p input=
if %input%==%num% goto win
if %input% lss %num% set morl="higher"
if %input% gtr %num% set morl="lower"
goto start
:win
cls
echo You won! the answer was %num%
pause
goto menu