control structure
do select numeric-expression (as alias)? ((case selector (| selector)* local-scope)+ (else local-scope)? done
do select
evaluates its ~numeric-expression~ argument, compares it against the numeric values or
ranges in the case
alternatives, then selects the alternative that applies. It is an error to have
more than one case
alternative apply to the same value.
If none of the case
alternatives apply, and there is an else
declaration, then
the else
declaration is selected. Otherwise, none of the clauses are selected.
If a clause was selected, the actions in that clause are performed. Otherwise, none of the actions are performed.
The numeric ranges are inclusive. If the value falls between the upper and lower bounds, or matches either
bound, the test succeeds and that case
alternative is selected.
It is an error for a selecting value to match more than one case
alternative. Each range set in
a do select
must describe a set of values separate from those in all the other range sets.
The following example shows how do select
is used to evaluate a numeric expression, and then
compare that expression against the numeric values or ranges in the case
alternative, in order to
select the alternative that applies. If none of the case
alternatives apply and there is
an else
clause, then the else
is selected.
process local integer i do select i case 1 | 3 | 5 output "d" % i || " is either 1, 3, or 5.%n" case 2 | 4 | 6 to 10 output "d" % i || " is either 2, 4, or 6 through 10.%n" else output "d" % i || " is something else entirely.%n" done