Prompts the user to make a choice in a batch program. Displays a specified
prompt and pauses for the user to choose from among a specified set of keys.
You can use this command only in batch programs.
For more information on the ERRORLEVEL parameter, see <CHOICE--Note> and the
CHOICE [/C[:]keys] [/N] [/S] [/T[:]c,nn] [text]
Specifies text you want to be displayed before the prompt. Quotation
marks are necessary only if you include a switch character (/) as part
of the text before the prompt. If you don't specify text, CHOICE
displays only a prompt.
Specifies allowable keys in the prompt. When displayed, the keys will be
separated by commas, will appear in brackets (), and will be followed
by a question mark. If you don't specify the /C switch, CHOICE uses YN
as the default. The colon (:) is optional.
Causes CHOICE not to display the prompt. The text before the prompt is
still displayed, however. If you specify the /N switch, the specified
keys are still valid.
Causes CHOICE to be case sensitive. If the /S switch is not specified,
CHOICE will accept either upper or lower case for any of the keys that
the user specifies.
Causes CHOICE to pause for a specified number of seconds before
defaulting to a specified key. The values for the /T switch are
Specifies the character to default to after nn seconds. The
character must be in the set of choices specified in the /C switch.
Specifies the number of seconds to pause. Acceptable values are from
0 to 99. If 0 is specified, there will be no pause before defaulting
said Microsoft but a zero won't work whether it's DOS 6.22 or Win98.
Hidden test exist temporary in the source of this file
For %%imposible in (64 32 16 8 4 2) do SET N= N/2 (devide N with 2)
My previous Batch program uses a third party utility "STRINGS.COM".
If a variable N was 64, then I wanted to use 32. If N was set to 32
, then I wanted 16 and so on... but I will very soon substitute the
"STRINGS.COM" file with the CHOICE command which performs; not only
addition/subtraction but also multiplying/divide is possible!
rem (N/2) Devide N with two:
ECHO %N%'|CHOICE /N/C24'8'''1'''''''3'''''''''''''''6
FOR %%N IN (1 2 4 8 16 32) DO IF ERRORLEVEL %%N SET N=%%N
Note about errorlevel 3 (easy to see):
if N contents no value, then the above syntax do returns N=2.
rem (X+8 -X/2)
Add 8 to X and then perform a subtraction of X devided with 2:
ECHO %X% | CHOICE /N/C:''EG24'8'''1'''''''3'''''''''''''''6 > NUL
FOR %%G IN (09 10 12 16 24 40) DO IF ERRORLEVEL G%%G SET X=%%G
if X contents no value, then the above syntax returns X= "empty".
rem (X+9 -X/2)
ECHO %X% | CHOICE /S/C'24'8''^1'''''''3''''''''''''e''6
FOR %%N IN (10 11 13 17 25 41) DO IF ERRORLEVEL ^%%N SET X=%%N
if X contents no value, then it returns X= "empty" but this example is
country dependent of the OS. In Denmark where: (ECHO is "not" off), an
exit code would be 30 (ECHO er slået fra), the variable X is set to 25.
Ignore the ^ in my above CHOICE syntax. It's just to remember me about
the value -8 in this subtraction.
regards B, and you know where to find my Homepage.
PS. HELP! I'll wait for your reply about my above English.
: End Of Mission Impossible.