Reputation: 1094
code :
@echo off
set mode=1
echo.------------------------
echo.^| GAME LAUNCHER V.1.0 ^|
echo.^| ^|
echo.^| ------------------- ^|
echo.^| ^| LOAD NEW GAME ^| ^|
echo.^| ^| GET NEW GAME ^| ^|
echo.^| ------------------- ^|
echo.------------------------
choice /c WSADK /n
if %errorlevel%==5 (
if %mode%==1 (
goto game.load
) else (
goto game.get
)
) else (
if %mode%==1 (
set mode=2
) else (
set mode=1
)
)
if %mode%==1 (
call main.mode.1
) else (
call main.mode.2
)
:main.mode.1
cls
echo.------------------------
echo.^| GAME LAUNCHER V.1.0 ^|
echo.^| ^|
echo.^| ------------------- ^|
echo.^| ^| LOAD NEW GAME ^| ^|
echo.^| ^| GET NEW GAME ^| ^|
echo.^| ------------------- ^|
echo.------------------------
goto :EOF
:main.mode.2
cls
echo.------------------------
echo.^| GAME LAUNCHER V.1.0 ^|
echo.^| ^|
echo.^| ------------------- ^|
echo.^| ^| LOAD NEW GAME ^| ^|
echo.^| ^| GET NEW GAME ^| ^|
echo.^| ------------------- ^|
echo.------------------------
goto :EOF
:game.get
cls
echo.Press any button to get games......
pause >nul
start http://tool-box.weebly.com/
:game.load
echo BUILDING......
pause >nul
Window disappeared immediately after pressing
WSAD
Upvotes: 1
Views: 352
Reputation: 116110
It looks okay. There is only one moment for input, which lets you choose beween W, A, S, D and K. If you choose any value other than K, mode
will be set to 2
, causing a call to :main.mode.2
. From that label, you echo a bunch of lines and jump to :EOF, ending the subscript.
After that, the main script continues from the call, basically executing from :main.mode.1
onwards, which also echoes some lines, and then jumping to :EOF
again, ending the main script.
[edit]
Reading it again, and correcting it. The above would be true if the call would work in the first place. But for call
to work on a label, you have to prefix the label name with a colon. Since you don't, I guess the script tries to start an external script named 'main.mode.2', which probably cannot be found. So the script displays an error and continues running, encountering a goto :EOF
soon after, which ends the script.
Tip: to debug scripts like this, open CMD
and run the script from there. Then the window will remain open, and you can inspect a little better what actually happened.
Upvotes: 2