Next: Case Else
Up: Keywords
Previous: As
  Contents
  Index
Case
Syntax:
CASE = value :statements block
CASE IS binary_op value :statements block
CASE IS value :statements block
CASE ranges :statements block
Statement Case is the part of Select Case construct - a powerful
alternative to switch-like constructs in other languages.
Case has four different forms as given in the syntax section. Each form has condition and block of statements that are executed if the condition holds.
Independently of the result of the previous Case block, execution always proceeds with the next Case, unless the shole Select Case is aborted using Exit Select statement.
In the first syntax case the control value (specified in Select Case)
is matched against test value.
Equality test operator can be substituted with any other binary ordering
operator. In the second syntax, binary_op is one of the following:
=, >, <, <>, <=, >=.
In the third syntax, value is any arbitrary expression that may or may not contain the control value.
And in the the last Case form you can use list of test expressions
and ranges. Syntax of ranges is following:
ranges := range
ranges , range;
range := expression to expression
expression.
Ranges with To keyword give the lower and the upper bound for the control value. Corresponding operations are less or equal for the lower bound and greater or equal for the upper bound.
Example: case 2, 7 to 17, 23 to 29, 97, q > 3
Note that it is possible to use Case constructs with non-numeric types and any arbitrary types if the corresponding operators are overloaded for the used types.
See also: Select Case (1.3.44), Case Else (1.3.5)
Next: Case Else
Up: Keywords
Previous: As
  Contents
  Index
root
2004-04-05