WELCOME to Free Self
Help Quick Facts
No Nonsense FREE Computer Answers from people just like you, in plain
English |
CHOICE
Syntax:
CHOICE [/C[:]choices] [/N] [/S] [/T[:]c,nn] [text]
Purpose: Used to provide a prompt so that a user can make a choice
while a batch program is running
Options
text - Used to specify text to be displayed before the prompt. When text
has not been specified, CHOICE will display only the prompt. You must use
quote marks around the text if you include a switch character (/) as part
of the text.
/C[:]choices The prompt - comprising a series of valid choices. The prompt
is displayed as the characters, separated by commas, enclosed in brackets,
and followed by a question mark. Default is Y N
/N Stops the prompt from being displayed, although text is still shown and
the choices keys are still valid.
/S Forces the choice keys to be case sensitive. By default they are not.
/T[:]c,nn Defaults choice to c after nn seconds. c must exist; nn must be
in the range 0 to 99.
text Text displayed before the prompt. Typically, text is used to expand
on the prompt.
c - Specifies the default key (character). The key must be one of those
specified in the /C switch.
nn - Specifies the length of the pause in seconds (0 to 99).
EXIT CODES:
0 CHOICE was terminated by Ctrl-C before a choice was entered.
1 The key corresponding to the first choice was pressed.
n The key corresponding to the nth choice was pressed
255 An error occurred.
Example
If you were writing a batch program and wanted to use the CHOICE command
to prompt the user to select from the keys Y, N, and C, you would enter
the following:
choice /c:ync
The user would see the following prompt:
[Y,N,C]?
To make it more obvious to the user exactly what they are selecting, you
could add some explanatory text to the prompt by entering,
choice /c:ync Yes, No, or Continue
The user would then see,
Yes, No, or Continue [Y,N,C]?
If you wanted to use the /T option to limit the amount of time a user has
to make a choice at the prompt you might enter,
choice /c:ync /t:c,10
The user would still see the prompt [Y,N,C]? from which they could make
their choice. If a selection was not made within 10 seconds the C option
would be assumed and the batch program would continue.
|