Computing.Net > Forums > Disk Operating System > 'choice' command isn't working

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

'choice' command isn't working

Reply to Message Icon

Name: nmv (by AP81)
Date: April 18, 2005 at 23:07:18 Pacific
OS: Win Me
CPU/Ram: 512 kingmax
Comment:

Hi all,

Am having some trouble with a small DOS program I am running on Windows Me. Anytime I try to use the choice command, it causes a continuous loop, e.g.

@ECHO OFF
ECHO select [1]test1 OR [2]test2
choice /c:12 /N
IF ERRORLEVEL 1 GOTO one
IF ERRORLEVEL 2 GOTO two

:one
echo choice is one
GOTO END

:two
echo choice is two
GOTO END

:END

Any ideas what I am doing wrong? Thanks.




Sponsored Link
Ads by Google

Response Number 1
Name: Nigel Spike
Date: April 18, 2005 at 23:29:33 Pacific
Reply:

Errorlevels always check from bigger to smaller, so:

IF ERRORLEVEL 5 ...
IF ERRORLEVEL 4 ...
IF ERRORLEVEL 3 ...
etc.

HTH
Nigel


0

Response Number 2
Name: nmv (by AP81)
Date: April 19, 2005 at 00:28:36 Pacific
Reply:

Nope, still doesn't work. I do have the error levels in decending order in my code...that was just a sample I typed.

Thanks anyway.


0

Response Number 3
Name: Mechanix2Go
Date: April 19, 2005 at 00:51:38 Pacific
Reply:

Hi Adam,

In order to get real help, you should post your EXACT code.

Nigel picked out the problem with what you posted. Now you say that's not what you're using.

M2


If at first you don't succeed, you're about average.


0

Response Number 4
Name: nmv (by AP81)
Date: April 19, 2005 at 01:26:30 Pacific
Reply:

I tested the code that I posted and it produced the same result. It's more or less the same.


0

Response Number 5
Name: jboy
Date: April 19, 2005 at 08:23:14 Pacific
Reply:

"It's more or less the same"

Really?

Programming (yes, even in DOS) requires a certain precision and attention to detail.

The 'example' you'd posted would not work for the reasons given, so one wonders what exactly your are doing

Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.


0

Related Posts

See More



Response Number 6
Name: Nigel Spike
Date: April 19, 2005 at 09:12:20 Pacific
Reply:

Maybe this is the most specific aid we may offer at this point: Documentation

Nigel


0

Response Number 7
Name: Valerie (by Garibaldi)
Date: April 19, 2005 at 20:42:15 Pacific
Reply:

Is Choice available in ME? See here:

http://www.computerhope.com/choicehl.htm#02

Good luck


0

Response Number 8
Name: Mechanix2Go
Date: April 19, 2005 at 22:46:50 Pacific
Reply:

Valerie,

It's more or less the same, to coin a phrase.

M2


If at first you don't succeed, you're about average.


0

Response Number 9
Name: Mike Newcomb
Date: April 21, 2005 at 08:46:28 Pacific
Reply:

shoudn't you have another END or GOTO somewhere, after IF ERRORLEVEL 2 etc.?

Good luck - Keep us posted.


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: 'choice' command isn't working

dos commands don't work www.computing.net/answers/dos/dos-commands-dont-work/5584.html

CDRom won't work in DOS www.computing.net/answers/dos/cdrom-wont-work-in-dos/1687.html

mouse doesn't work www.computing.net/answers/dos/mouse-doesnt-work/13633.html