TAL Reference Manual
Expressions
TAL Reference Manual—526371-001
4-21
IF Expression
You can nest CASE expressions. CASE expressions resemble unlabeled CASE
statements except that CASE expressions select
expressions rather than statements.
Example of CASE Expression
This example selects an expression based on the value of A and assigns it to X:
INT x, a, b, c, d;
!Code to initialize variables
x := CASE a OF
BEGIN
b; !If A is 0, assign value of B to X.
c; !If A is 1, assign value of C to X.
d; !If A is 2, assign value of D to X.
OTHERWISE -1; !If A is any other value,
END; ! assign -1 to X.
IF Expression
The IF expression conditionally selects one of two expressions, usually for assignment
to a variable.
condition
is either:
•
A conditional expression
•
An INT arithmetic expression. If the result of the arithmetic expression is not 0,
the condition is true. If the result is 0, the condition is false
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
VST0407.vsd
IF
condition
THEN
expression
ELSE
expression