TAL Reference Manual
Expressions
TAL Reference Manual—526371-001
4-20
CASE Expression
3. This example mixes the assignment form with a relational form. It assigns the
value of B to A, then checks for equality with 0:
IF (a := b) = 0 THEN ... ;
CASE Expression
The CASE expression selects one of several expressions.
selector
is an INT arithmetic expression that selects the expression to evaluate.
expression
is either:
•
An INT arithmetic expression
•
A conditional expression (excluding a relational operator with no operands), the
result of which has data type INT
OTHERWISE expression
specifies the expression to evaluate if selector does not select an expression in the
BEGIN clause. If you omit the OTHERWISE clause and an out-of-range case
occurs, results are unpredictable.
Usage Considerations
All expressions in the CASE expression must have the same data type.
The compiler numbers each
expression in the BEGIN clause consecutively, starting
with 0. If the
selector matches the compiler-assigned number of an expression, that
expression is evaluated and becomes the result of the CASE expression. If the
selector does not match a compiler-assigned number, the OTHERWISE expression is
evaluated.
CASE
selector
OF BEGIN
expression
;
END
otherwise expression
;
VST0406.vsd