VOGONS

Common searches


Choice command

Topic actions

First post, by Supa

User metadata

Hello,

I've got some problem at building a .bat menu for my games.
Apparently, either I forgot how to use the choice command, either DosBox doesn't handle it the way it should.

Here's a part of my code :

@echo off
echo Menu
echo ====
echo.
echo 1. Point'n'click
echo 2. Gestion
echo 3. STR
echo 4. Doom-like
echo 5. Puzzle
echo 6. Aventure-Action
echo 7. ...
echo.
echo.
choice /c:1234567890AB
if errorlevel 1 goto PnC
if errorlevel 2 goto Gestion
if errorlevel 3 goto STR
if errorlevel 4 goto Doomlike
if errorlevel 5 goto Puzzle
if errorlevel 6 goto AA
if errorlevel 7 goto 7
if errorlevel 8 goto 8
if errorlevel 9 goto 9
if errorlevel 10 goto 0
if errorlevel 11 goto A
if errorlevel 12 goto B
goto exit

Whatever the choice I make, I keep going with the same errorlevel choice (1 in this case).

Can someone help me with it ?

Reply 2 of 23, by JHawx

User metadata
Rank Newbie
Rank
Newbie

you might know... i got exactly same problem even though my list seams to be clear of thet problem... what am i doing wrong?

@echo off
:start
cls

echo
echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍ»
echo º Games on menu - press # and [enter] º works º
echo ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÎÍÍÍÍÍÍÍ¹Ú ¿
echo º 1. WingCommander - Privateer º N º * Y = Fully works
echo º 2. Master of Magic º Y º * n/S = No Sounds
echo º 3. Master of Orion 1 º Y º * N = Not working
echo º 4. Mega-Lo-Mania º Y º
echo º 5. Legend of kyrandia 2 - Hand of fate º Y ºÀ Ù
echo º 6. Legend of kyrandia 3 - Malcolmïs revenge º n/S º
echo º 7. SimCity 2000 º Y º
echo º 8. Princess maker 2 º Y º
echo º X. Exit menu º exits º
echo º º º
echo ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍͼ
echo
choice:/c12345678x
if errorlevel 8 goto pm2
if errorlevel 7 goto sc2000
if errorlevel 6 goto kyrandia3
if errorlevel 5 goto kyrandia2
if errorlevel 4 goto megalomania
if errorlevel 3 goto moo
if errorlevel 2 goto mom
if errorlevel 1 goto priv
if errorlevel x goto exit

:pm2
call mount x d:\oldies\pm2\pm2
x:
pm2.exe

:sc2000
call mount x d:\oldies\simcity2000
x:
sc2000.exe

:kyrandia3
call mount x d:\oldies\kyrandia3
x:
start.bat

:kyrandia2
call mount x d:\oldies\kyrandia2
x:
hof.exe

:megalomania
call mount x d:\oldies\MegaLoMania
x:
mega.exe

:moo
call mount x d:\oldies\moo
x:
orion.exe
Show last 16 lines

:mom
call mount x d:\oldies\mom
x:
madic.exe

:priv
call mount x d:\odlies\privateer
x:
loadhigh priv.exe

:exit
z:
cls
goto end

Reply 4 of 23, by `Moe`

User metadata
Rank Oldbie
Rank
Oldbie

The command is called "choice", not "choice:". The switch goes like "/c:1234", not like "/c1234". Move around that colon and it should work 😀

Reply 5 of 23, by JHawx

User metadata
Rank Newbie
Rank
Newbie

did what you said moe, it worked... thanx

By the way.

== means that the mach must be EQUAL to character. without this the code works too, but without == it takes upper & lowercase letters too. so without these == marks, it works better... i think...

menu works now in visual base, but it asks guestion [y/n]

should it ask letter?
now it is just boolean question. still accepts all letters as base...

what am i still makin wrong? Is it correct to use CALL funktion to start mounting on the code? 😅

any other things i should know? also can it be preventeed that console says echo off every single time echo goes off?

this topic turned out great manual for others to build own menus... heh
🙄

Reply 6 of 23, by `Moe`

User metadata
Rank Oldbie
Rank
Oldbie

Okay, you've pointed me to a small incompatibility to real DOS choice: in DOS, it would display [12345..], the actual choices. I've hardcoded that Y/N thingy in dosbox. You can put your own prompt on the choice line like this:
choice /c:1234 /n Please choose one:

those "echo is off" messages are cause by lines containing just "echo" all alone. What you wanted is an empty line, for that use "echo." (note the dot, directly after echo, with no space in between)

"call" is only needed when starting other batch files. Without "call", they don't return back to the calling batch file.

Reply 7 of 23, by `Moe`

User metadata
Rank Oldbie
Rank
Oldbie

By the way, if you want to contribute you are welcome to summarize your newly learned wisdom in the DosBox Wiki. That way other users can benefit as well 😉

Reply 9 of 23, by JHawx

User metadata
Rank Newbie
Rank
Newbie

Now i´we done it... i wrote the tutorial files for making simple menus. any comments on it? aster this is accepted by 2 other users, i shall submit it to DosBox Wiki.

Attachments

  • Filename
    simplemenus.doc
    File size
    83.5 KiB
    Downloads
    303 downloads
    File comment
    SimpleMenus word document. Contains instructions how to create commandline menus of DosBox for newbies.

    single menu system only. 2 menu system comming soon.
    File license
    Fair use/fair dealing exception

Reply 10 of 23, by `Moe`

User metadata
Rank Oldbie
Rank
Oldbie

Looks quite nice. I have a bunch of remarks, but more about that later.

Why do you have to use "call mount"? I surely don't. What happens if you don't use call?

Reply 11 of 23, by JHawx

User metadata
Rank Newbie
Rank
Newbie

in my case, it did not work.

besides... this is the correct way to do it. both works. but basicly the mount is diffirent batch command. mounting apearently makes virtual drives that is set with parameters. basicly in coding lanquake, it has to be called to correctly work. this is due usage of 2 batch codes.

and please. do make those remarks... could you do it with msoffice and make those remarks with blue color.

and send them to me.
email: jhawx@tiscali.fi

Reply 13 of 23, by JHawx

User metadata
Rank Newbie
Rank
Newbie

´hey wait a second... Com file is advanced bat file. coms can be created from bat files. (did you know that) and it is still funktion command, soforth it can be "called" succesfully.

But if you dont need call funktion, how come my code did not work? coding... mystery for all. 😒

But if it works, what damage can it do? it might even work better for some other systems. Dont know about other systems... just rationalizing.

i am just information handling tradenome student who has lessons on c#. This is why i want to know how these codes work.

Giwe me feedback on the document and error corrections so i can write the tutorial for other users. You might be also credited for your help... 😁

Reply 14 of 23, by HunterZ

User metadata
Rank l33t++
Rank
l33t++

No, .com files are not advanced .bat files; .COM files are simple, raw machine-language programs. I know this because I've written some assembly language programs for DOS.

The programs that turn .BAT files into .COM files probably just encode the BAT file instructions into a simple assembly language program that calls command.com over and over with those commands. Wouldn't know for sure without researching it though.

Reply 15 of 23, by JHawx

User metadata
Rank Newbie
Rank
Newbie

i stand corrected... 😠

...now... how about those corrections on the file so others might start to learn on their own to create batch choise menus? 😒

called or not, ill change the remark so that you can use both. i found that 6 of my 45 games did not work without call command...

also you can call second menu not connected to first menu by calling it. (calling secondary bat.) but got errors if used without it.

so if your funktions are simple, use without call, but if you add other menus to it, use call. But to remind you, using call funtion adds compability in future, if you add options to your menus.

i dont know if this funktion is hardcoded diffirently on dosbox, but if it tries to emulate dos, this way it was done with dos 5.0 ... dont know if it was like this with 6.0

also it r.e.a.l.l.y . d.o.e.s. n.o.t. m.a.t.t.e.r on simple one menu sheet system i try to teach to create in this tutorial. I just assumed that you need to call them if used higher funktions. Dont like it? make your own tutorial on subject (better than mine of course) and call my tutorial piece of *peeb* in it... sorry. lost my temper back there 😢 . it is written in 37minutes, so it tends to be little crappy. thats why it sucks, but remind that it still is BETA version. it is still ver1.0 (because it works with these settings, even though buggy. Next versions are updates so it works BETTER)

But to make perfect scenario, SEND THOSE CORRECTIONS TO ME AS I ASKED... PLEASE!

and thanx for telling me what coms are... really did not knew, but have been using those .bat to .com converters... works on 75% of the cases.

Reply 17 of 23, by JHawx

User metadata
Rank Newbie
Rank
Newbie

sorry... hunter2 bit gnew my end of nerve...

there is no rush. these things ere going to be better through time.
cant quite figure out the system that dosbox uses for letter assignment. (i cant use letters for selection crtieria... ie if errorlevel x goto exit) has someone got this one to work?

Reply 18 of 23, by `Moe`

User metadata
Rank Oldbie
Rank
Oldbie

It's real simple:

choice /c:abcx Choose one of [ABCX]: /n

will give you errorlevel 4 on "x", 3 on "c", 2 on "b" and 1 on "a". The n'th letter (or number) will create errorlevel n.