VOGONS

Common searches


DosBox en Bat??

Topic actions

First post, by netolk

User metadata
Rank Newbie
Rank
Newbie

Hi there, I has maked a Menu in Bat. When I try to run it in DOSBOX it jams. Can Anybody tell me why?

this is the code

@ECHO off
cls
:start
ECHO.
ECHO.
ECHO 1.Lemmings
ECHO.
ECHO 2.Pacman
ECHO.
ECHO 3.Prehistorik
ECHO.
ECHO 4.Prehistorik2
ECHO.
ECHO 5.Exit
ECHO.
set choice=
set /p choice=Type the number to print text.
if not '%choice%'=='' set choice=%choice:~0,1%
if '%choice%'=='1' goto Lemmings
if '%choice%'=='2' goto Pacman
if '%choice%'=='3' goto Prehistorik
if '%choice%'=='4' goto Prehistorik2
if '%choice%'=='5' goto Exit
ECHO "%choice%" is not valid please try again
ECHO.
goto start

:Lemmings
cd Lemmings
lemvga.com
cd ..
Menu.bat
goto end
:Pacman
cd pacman
pacpc2.exe
cd ..
Menu.bat
goto end
:Prehistorik
cd prehistorik
historik.exe
cd..
Menu.bat
goto end

:Prehistorik2
cd prehistorik2
pre2.exe
cd..
menu.bat
goto end

:Exit
exit
goto end

:end

grtz. netolk

Reply 2 of 21, by MiniMax

User metadata
Rank Moderator
Rank
Moderator

It is because of that

@ECHO off

at the start. Remove it and you will see what is wrong.

DOSBox 60 seconds guide | How to ask questions
_________________
Lenovo M58p | Core 2 Quad Q8400 @ 2.66 GHz | Radeon R7 240 | LG HL-DT-ST DVDRAM GH40N | Fedora 32

Reply 5 of 21, by ADDiCT

User metadata
Rank Oldbie
Rank
Oldbie

Remove the "set /p" stuff and use something like CHOICE.COM or 4DOS?

You can develop a _real_ menu system with WBAT. I've created a full-blown menu system with all my installed DOS games, and it looks terrific. It's quite a bit of work, though.

Reply 9 of 21, by ripsaw8080

User metadata
Rank DOSBox Author
Rank
DOSBox Author

The CHOICE command is built into DOSBox, no need to use an external program.

choice /N /C:12345 Type the number to print text.
if errorlevel 5 goto Exit
if errorlevel 4 goto Prehistorik2
if errorlevel 3 goto Prehistorik
if errorlevel 2 goto Pacman
if errorlevel 1 goto Lemmings

It is important to test ERRORLEVEL in descending order for something like this because lower levels test TRUE compared to higher levels.

Reply 15 of 21, by ripsaw8080

User metadata
Rank DOSBox Author
Rank
DOSBox Author

It should work. You're probably not doing it correctly.

choice /N /C:ABCDEFGHIJKLM Type the letter to print text.
if errorlevel 13 goto label13
if errorlevel 12 goto label12
...
if errorlevel 1 goto label1

I used the ellipsis there because I didn't want to type all 13 of them. Did you try to use "errorlevel A"? The ERRORLEVEL is a number, and in the case of the CHOICE command, it corresponds to the number of the choice in the list of possible choices.

However, if you are using this batch as a game launcher, you really will find using a frontend much more capable and accommodating.

Reply 16 of 21, by gidierre

User metadata
Rank Member
Rank
Member
ripsaw8080 wrote:

Same behavior in MS-DOS; apparently it is a less-than-or-equal-to comparison.

actually
if errolevel 1
has always coincided with
greater-or-equal-to 1
and not less-than-or-equal-to

in fact if one should write
if errorlevel 0 goto :zero
if errolevel 1 goto :one

that wouldn't do because with errorlevel==1 it would goto :zero as well

IOW if error level 0 always rings TRUE

or, it would have to read
if not errorlevel 1 goto :zero
for it to be correct IMO.

ripsaw8080 wrote:

Did you try to use "errorlevel A"?

I don't think that would work either.

We often forgive those who bore us, but we cannot forgive those whom we bore. (La Rochefoucauld)

Reply 17 of 21, by ripsaw8080

User metadata
Rank DOSBox Author
Rank
DOSBox Author

Please don't confuse the issue. It's simply a matter of which terms you place on which side of the equation. It's less than or equal if you're comparing the test value in the batch file to the actual level value in DOS.

In other words: "if the errorlevel is at least <some number> then <do something>"

I used the "errorlevel A" to ask if that was the mistake that was made, obviously it won't work because it's a numeric value.

Reply 18 of 21, by gidierre

User metadata
Rank Member
Rank
Member

OK, then, obviously I must have gotten your statement wrong, as if it were somewhat problematic,
but I was just knee-jerk reacting along the old guideline to reassert that between errorlevel and n
a '>=' mark must be always seen etc.

I don't want to confuse any issues 😦

We often forgive those who bore us, but we cannot forgive those whom we bore. (La Rochefoucauld)