Jump to content

'ask' in XP


Recommended Posts

Guest someone watching
Posted

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

  • Replies 8
  • Created
  • Last Reply
Guest Pegasus \(MVP\)
Posted

Re: 'ask' in XP

 

 

"someone watching" <nospam@bogusaddress.com> wrote in message

news:eDaMV690IHA.1240@TK2MSFTNGP02.phx.gbl...

> 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.

Guest someone watching
Posted

Re: 'ask' in XP

 

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

 

___

 

"Pegasus (MVP)" <I.can@fly.com.oz> wrote in message

news:#b7$BE#0IHA.4040@TK2MSFTNGP04.phx.gbl...

>

> "someone watching" <nospam@bogusaddress.com> wrote in message

> news:eDaMV690IHA.1240@TK2MSFTNGP02.phx.gbl...

> > 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.

>

>

Guest Pegasus \(MVP\)
Posted

Re: 'ask' in XP

 

 

"someone watching" <nospam@bogusaddress.com> wrote in message

news:O48h%23O%230IHA.4848@TK2MSFTNGP05.phx.gbl...

> 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

.. . .

Guest someone watching
Posted

Re: 'ask' in XP

 

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

__

"Pegasus (MVP)" <I.can@fly.com.oz> wrote in message

news:OSDpFZ#0IHA.1628@TK2MSFTNGP03.phx.gbl...

>

> "someone watching" <nospam@bogusaddress.com> wrote in message

> news:O48h%23O%230IHA.4848@TK2MSFTNGP05.phx.gbl...

> > 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

> . . .

>

>

Guest someone watching
Posted

Re:follow-up questions

 

Re:follow-up questions

 

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

___

"someone watching" <nospam@bogusaddress.com> wrote in message

news:eDaMV690IHA.1240@TK2MSFTNGP02.phx.gbl...

> 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

>

>

Guest Pegasus \(MVP\)
Posted

Re: Re:follow-up questions

 

Re: Re:follow-up questions

 

 

"someone watching" <nospam@bogusaddress.com> wrote in message

news:etj7zgG1IHA.4040@TK2MSFTNGP04.phx.gbl...

> 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.


×
×
  • Create New...