The problem is when running the game, if I leave the field blank and just hit enter, the window closes.
When running the game in Command Prompt window from directory (to stop it closing), I see the above error message.
The "invalid selection" 'goto start' works fine if a character is entered, it all has to do with there being a blank field.
I have:
- tried
if not defined
goto
- tried encasing variables in ""
But nothing seems to work!
:start
cls
echo You need to decide NOW, are you going to barricade yourself in (Bug in),
echo or go to somewhere out of town (Bug out)?
echo.
set /p bug=I want to bug
if %bug%==In goto bugin
if %bug%==Out goto bugout
if %bug%==in goto bugin
if %bug%==out goto bugout
echo.
echo Invalid selection
pause
cls
goto start
If the user inputs something blank the
if
statement fails:So surrounding the statement in quotes will result in:
Which should work.
Mona