Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: choice input  (Read 2502 times)

0 Members and 1 Guest are viewing this topic.

wizzy

  • Guest
choice input
« on: November 28, 2005, 08:59:20 AM »
When I use the CHOICE option my program works , I just needed to change it with the SET command

When I use it on NT, it says that it doesn't recognize the command...

Is there any other solution for the CHOICE command or do I use a wrong syntax:

This is what I use:
CHOICE /N /C:123 PICK A NUMBER (1, 2, or 3)%1

IF ERRORLEVEL ==3 GOTO THREE
IF ERRORLEVEL ==2 GOTO TWO
IF ERRORLEVEL ==1 GOTO ONE
GOTO END
:THREE
ECHO YOU HAVE PRESSED THREE
GOTO END
:TWO
ECHO YOU HAVE PRESSED TWO
GOTO END
:ONE
ECHO YOU HAVE PRESSED ONE
:END

Please can someone provide me with some feedback

Big thanks,
Wizzy

Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: choice input
« Reply #1 on: November 28, 2005, 01:38:43 PM »
For whatever reason, Microsoft discontinued CHOICE on NT machines. For better or worse they added the /p switch to the SET command:

Code: [Select]

set /p var=PICK A NUMBER (1, 2, or 3)
if %var=1 goto one
if %var=2 goto two
if %var=3 goto three
GOTO END
:THREE
ECHO YOU HAVE PRESSED THREE
GOTO END
:TWO
ECHO YOU HAVE PRESSED TWO
GOTO END
:ONE
ECHO YOU HAVE PRESSED ONE
:END


Hope this helps.  8)
The true sign of intelligence is not knowledge but imagination.

-- Albert Einstein

wizzy

  • Guest
Re: choice input
« Reply #2 on: November 29, 2005, 02:27:08 AM »
It looks very nice and works for XP but still not in NT  :'(

???

Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: choice input
« Reply #3 on: November 29, 2005, 05:38:12 AM »
I truly had a bad day yesterday. Not only is the code posted wrong (incomplete) but you're right, the /p switch didn't show up until W2K.

If you have access to a Win9x machine you can borrow a copy of CHOICE or you can get it from the MS-DOS 6.22 Supplemental Disk

Good luck. 8)
The true sign of intelligence is not knowledge but imagination.

-- Albert Einstein

wizzy

  • Guest
Re: choice input
« Reply #4 on: November 29, 2005, 06:25:44 AM »
I copied a choice.com file from a Win95 pc and...

...YOEHOE it's working...


:) :) :) :)

Thanks a lot SideWinder !!