'ask' in XP

S

someone watching

In the old DOS days I used a program called 'ASK' in batch files which
allowed me to select a response to a question. According to the answer
(eg, Y/N) the batch file would then branch (goto to the appropriate
label) according to the answer. Does XP have an equivalent? If so, is
there also a help file you can point me to for syntax and errorlevel
information?

Thanks
Vic
 
P

Pegasus \(MVP\)

someone watching said:
In the old DOS days I used a program called 'ASK' in batch files which
allowed me to select a response to a question. According to the answer
(eg, Y/N) the batch file would then branch (goto to the appropriate
label) according to the answer. Does XP have an equivalent? If so, is
there also a help file you can point me to for syntax and errorlevel
information?

Thanks
Vic

Start a Command Prompt, then type set /? and watch for
the /P option. The user input can be anything, not just Y/N,
but you need to check it yourself.
 
S

someone watching

Wow, I saw the /P help you mentioned. Wish they had 'instructions for
dummies'. Tried fiddling using the expressions in a file (test.cmd) but
am not making headway. If anyone can help with a simple example it would
sure be appreciated!

eg.

echo.
(command) Would you like to go to label A or label B? AB
if errorlevel 2 goto B
if errorlevel 1 goto A

___
 
P

Pegasus \(MVP\)

someone watching said:
Wow, I saw the /P help you mentioned. Wish they had 'instructions for
dummies'. Tried fiddling using the expressions in a file (test.cmd) but
am not making headway. If anyone can help with a simple example it would
sure be appreciated!

eg.

echo.
(command) Would you like to go to label A or label B? AB
if errorlevel 2 goto B
if errorlevel 1 goto A

Not quite. You need to forget about the clumsy
ErrorLevel stuff used by ask.com. Try this instead:
@echo off
:again
set /P name=Please enter your name:
if "%name%"=="" goto :eof
if /i "%name%"=="Peter" goto Sales
if /i "%name%"=="Jane" goto Accounting
echo Sorry, I don't know a person named "%name%".
goto again

:Sales
.. . .
goto :eof

:Accounting
.. . .
 
S

someone watching

Looks like that's the kind of 'detail for dummies' I needed <g>!
One last question; noticed the :eof, is this a 'hidden' label which
stands for end of file? or is it like using the exit command?

Thanks Pegasus, your response was very helpful!

Vic
__
 
S

someone watching

At the risk of seeming pesky:

Found I have CHOICE.EXE from W2K (I think, 21KB Dec 21, 1999). Tried
using that in a CMD file. All is well except it does not accept input
from the Esc key. I like to use Esc as the ultimate abort (escape hatch
<g>). Is it possible to have CHOICE accept Esc as a choice?

Lastly, have not tried the set /p command with acceptance of Esc
character. Do you know if set /p will accept Esc key input?

Thanks
Vic
___
 
P

Pegasus \(MVP\)

someone watching said:
At the risk of seeming pesky:

Found I have CHOICE.EXE from W2K (I think, 21KB Dec 21, 1999). Tried using
that in a CMD file. All is well except it does not accept input from the
Esc key. I like to use Esc as the ultimate abort (escape hatch <g>). Is it
possible to have CHOICE accept Esc as a choice?

Lastly, have not tried the set /p command with acceptance of Esc
character. Do you know if set /p will accept Esc key input?

Thanks
Vic

AFAIK, choice.exe was a Win98, not a Win2000 command. About
pressing Esc - why don't you give it a try yourself to see what happens?
Note that in my first response I gave you the standard method for
handling blank input. Not also you that the you MUST press Enter
after typing your response.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top