Contents Up << >>
Case statements
The case statement is used to select a block of statements to execute based
on the value of some expression. The grammar rule for the case statement
is:
Each alternative to be chosen from contains a choices part that indicates
for what values of the expression that alternative should be chosen.
The expression is first evaluated. Sequentially, from top to bottom, the
value of the expression is compared with the choices of the alternatives.
The first alternative found whose choices include the value of the expression
is the alternative that will be executed. Only one alternative is chosen
(the first one). If none of the choices in the case statement includes the
value of the expression, then it is an error and execution will be stopped.
The OTHERS choice will match any value of the expression. If the OTHERS choice
appears, it must be the last alternative.