VOGONS

Common searches


First post, by Binarypasta

User metadata
Rank Newbie
Rank
Newbie

Hey everybody, i tried to make a quick-launch script, as i did as a kid. However, i kind get the "Choice" command to work, and neither the "Set". (The set is not listed in the wiki as a legal command, so i'm not to surprised there)

EDIT: This is of course for a DOSBox specific setup, not the windows command-line.

How would i go around to do this then? Is there something i have set up wrong, the choice works perfectly in the windows cmd. (Thou i don't remember using that command ever before)

Here's my code so far:
(With stylish written menu, done in ECHO, but I've excluded that from here, as it works fine.)

CHOICE /C 123456789 /M "Enter your choice:"
REM - List errorlevels in decreasing order.
IF ERRORLEVEL 9 GOTO End
IF ERRORLEVEL 8 GOTO End
IF ERRORLEVEL 7 GOTO End
IF ERRORLEVEL 6 GOTO End
IF ERRORLEVEL 5 GOTO End
IF ERRORLEVEL 4 GOTO BAT4
IF ERRORLEVEL 3 GOTO BAT3
IF ERRORLEVEL 2 GOTO BAT2
IF ERRORLEVEL 1 GOTO BAT1
:BAT1
start bstone.bat
GOTO End
:BAT2
start supaplex.bat
GOTO End
:BAT3
start jazz.bat
GOTO End
:BAT4
start raptor.bat
GOTO End
:End
cd..

And here's what i've tried with the SET command, if that can help me get further:

SET /P M=Type 1, 2, 3, 4, 5, 6, 7, 8, 9, e, or E then press ENTER:
REM - This is the input directioner.
IF %M%==1 GOTO BAT1
IF %M%==2 GOTO BAT2
IF %M%==3 GOTO BAT3
IF %M%==4 GOTO BAT4
IF %M%==5 GOTO BAT5
IF %M%==6 GOTO BAT6
IF %M%==7 GOTO BAT7
IF %M%==8 GOTO BAT8
IF %M%==9 GOTO BAT9
IF %M%==e GOTO End
IF %M%==E GOTO End
:BAT1
start bstone.bat
GOTO End
...
Last edited by Binarypasta on 2017-08-02, 21:30. Edited 2 times in total.

Reply 1 of 4, by gerwin

User metadata
Rank l33t
Rank
l33t

In an example I have here it is like this for keys 1,2,3,4,5,s,x:
"CHOICE /C:12345sx /N"

There are different implementations of 'choice' in Windows.

Edit: removed attachment, did not notice this is DosBox specific.

Last edited by gerwin on 2017-08-02, 17:24. Edited 1 time in total.

--> ISA Soundcard Overview // Doom MBF 2.04 // SetMul

Reply 2 of 4, by Qbix

User metadata
Rank DOSBox Author
Rank
DOSBox Author

why use "start" to go the other batch file ?
That is not a DOS command. You have to use CALL instead

Water flows down the stream
How to ask questions the smart way!

Reply 3 of 4, by Binarypasta

User metadata
Rank Newbie
Rank
Newbie
Qbix wrote:

why use "start" to go the other batch file ?
That is not a DOS command. You have to use CALL instead

Roger that, i will change that. I haven't touch DOS or batch files in at least fifteen years, so i had to look up a few things, and what works in tutorials today, might not reflect legacy support i realize now!

Reply 4 of 4, by Binarypasta

User metadata
Rank Newbie
Rank
Newbie
gerwin wrote:

In an example I have here it is like this for keys 1,2,3,4,5,s,x:
"CHOICE /C:12345sx /N"

This solved the problem. For potential google searches, see the coded that ended up working down below:

@ECHO OFF
CLS
REM - This is the visual part of the script
:MENU
ECHO.
ECHO ......................................................
ECHO Select game, or task, by number, press enter
ECHO ......................................................
ECHO.
ECHO 1 - Blake Stone 6 -
ECHO 2 - SupaPlex 7 -
ECHO 3 - Jazz Jazk Rabit 8 -
ECHO 4 - Raptor 9 -
ECHO 5 - e - EXIT script
ECHO.
REM - This set the game batch file directory
cd GAMES
CHOICE /C:123456789 /N "Enter your choice:"
REM - List errorlevels in decreasing order.
IF ERRORLEVEL 9 GOTO End
IF ERRORLEVEL 8 GOTO End
IF ERRORLEVEL 7 GOTO End
IF ERRORLEVEL 6 GOTO End
IF ERRORLEVEL 5 GOTO End
IF ERRORLEVEL 4 GOTO BAT4
IF ERRORLEVEL 3 GOTO BAT3
IF ERRORLEVEL 2 GOTO BAT2
IF ERRORLEVEL 1 GOTO BAT1
:BAT1
CALL bstone.bat
GOTO End
:BAT2
CALL supaplex.bat
GOTO End
:BAT3
CALL jazz.bat
GOTO End
:BAT4
CALL raptor.bat
GOTO End
:End
cd..