VOGONS

Common searches


First post, by phil12345678910

User metadata
Rank Newbie
Rank
Newbie

Hi,

I just want to make a simple menu

ERRORLEVEL is always empty

@echo off
cls
echo ===========================
echo DOSBox Game Menu
echo ===========================
echo 1. Casino Games
echo 2. Ante-Upa
echo 3. Lode Runner
echo ===========================
choice /c123 /n "Select an option:"

echo Selected option: %ERRORLEVEL%

if %ERRORLEVEL%==1 (
echo "launching casino games"
rem mount a: W:\GAMES\Poker\CasinoGames
rem a:
rem runme.bat
goto end
)

if %ERRORLEVEL%==2 (
echo "launching Ante Up"
rem mount a: W:\GAMES\Poker\Ante-Upa
rem a:
rem FNPC.EXE
goto end
)

if %ERRORLEVEL%==3 (
echo "launching Lode Runner"
rem mount a: W:\GAMES\RETRO\DOS\abandonware\LODERUN
rem a:
rem jouer.bat
goto end
)

:end

image.png

thanks for your help

Reply 1 of 3, by Dominus

User metadata
Rank DOSBox Moderator
Rank
DOSBox Moderator

moved to DOSBox forums

Windows 3.1x guide for DOSBox
60 seconds guide to DOSBox
DOSBox SVN snapshot for macOS (10.4-11.x ppc/intel 32/64bit) notarized for gatekeeper

Reply 3 of 3, by Robbbert

User metadata
Rank Member
Rank
Member

if errorlevel 3 - you don't need the % or ==

Also errorlevel 1 means 1 or greater.

So you have to invert your if statements - put the test for 3 first

I don't know anything about putting statements in ( ) blocks - is that a thing?

I normally just say something like:

if errorlevel 3 goto L3
if errorlevel 2 goto L2
etc

then
:L3
statements
goto end

:L2
statements
goto end

etc etc

:END
exit