Rob van der Woude's Scripting Pages

Help text for SecondChoice.cs

(view help text of SecondChoice.cs as plain text)

SecondChoice.exe,  Version 1.02
Alternative to Windows' native CHOICE command.
Like CHOICE, SecondChoice allows users to select one item from
a list of choices and returns the index of the selected choice.
Unlike CHOICE, SecondChoice also returns the default value on
pressing the Enter key (besides after timeout expiration).
And unlike CHOICE, SecondChoice accepts a space in the list of
choices if that list is in doublequotes.

Usage:     SECONDCHOICE  [ options ]

Options:   /C choices    Specifies the list of Choices to be created.
                         Default list is "YN".
           /CS           Enables Case-Sensitive choices to be selected.
                         By default, the utility is case-insensitive.
           /D default    Specifies the Default choice after the timeout
                         expires or after pressing Enter.
                         The default character must be in the list of
                         choices specified by /C option.
           /M message    Specifies the Message to be displayed before
                         the prompt. If not specified, the utility
                         displays only a prompt.
           /N            Hides the list of choices in the prompt.
                         The message before the prompt is displayed
                         and the choices are still enabled.
           /T timeout    The number of seconds to pause before a default
                         choice is made. Acceptable values are from 0 to
                         86400 (24 hours). If 0 is specified, there will
                         be no pause and the default choice is selected.

Notes:     The ERRORLEVEL environment variable is set to the index of the
           key that was selected from the set of choices. The first choice
           listed returns a value of 1, the second a value of 2, and so on.
           Invalid choices are ignored.
           If SecondChoice detects an error, it returns ERRORLEVEL 255, if the
           user presses ESC, CTRL+C or CTRL+BREAK, the ERRORLEVEL will be 0.
           Pressing CTRL+BREAK will also be passed on to the hosting process.
           Besides spaces between switches and values, colons or equal signs
           are accepted too, e.g. /C choices or /C:choices or /C=choices are
           all accepted.
           SecondChoice also accepts a space as a valid choice; make sure you
           place the list of choices in doublequotes if you want to use a space
           in the list of choices, e.g. /C " ABC" or /C:" ABC" or /C=" ABC".

Examples:  SECONDCHOICE /C YNC /M "Press Y for Yes, N for No or C for Cancel."
           SECONDCHOICE /T=10 /C=YNC /D=C /M="Y=yes, N=no, C or timeout=cancel"
           SECONDCHOICE /C YN /N /D Y /M "Press Enter or Y for Yes, or N for No"
           SECONDCHOICE /C:AB /M:"Select A for option 1 and B for option 2."
           SECONDCHOICE /C 12 /N /M "Select 1 for option 1 and 2 for option 2."

Credits:   Code to gracefully exit on Ctrl+Break by Alois Kraus

Written by Rob van der Woude

page last uploaded: 2017-03-25, 21:31