Example
The batch file below gives the user three choices. The user is directed depending upon his input by evaluating the exit code using the IF ERRORLEVEL
command (which tests on "greater or equal"). The selected choice is then printed to the screen using the ECHO
command.
- Note that the example uses the DOS syntax. This example requires slight adjustments before it applies directly to Windows versions of the
CHOICE
command. - Note that the IF command, when checking the ERRORLEVEL, compares the number and matches if ERRORLEVEL is equal to or higher than that number. Because of this IF ERRORLEVEL comparisons should be done in decrementing order.
Read more about this topic: Choice (command)
Famous quotes containing the word example:
“Our intellect is not the most subtle, the most powerful, the most appropriate, instrument for revealing the truth. It is life that, little by little, example by example, permits us to see that what is most important to our heart, or to our mind, is learned not by reasoning but through other agencies. Then it is that the intellect, observing their superiority, abdicates its control to them upon reasoned grounds and agrees to become their collaborator and lackey.”
—Marcel Proust (18711922)