TAL Reference Manual

Expressions
TAL Reference Manual526371-001
4-22
IF Expression
Usage Considerations
If the condition is true, the result of the THEN expression becomes the result of the
overall IF expression.
If the
condition is false, the result of the ELSE expression becomes the result of the
overall IF expression.
You can nest IF expressions within an IF expression or within other expressions. The
IF expression resembles the IF statement except that the IF expression:
Requires the ELSE clause
Contains expressions, not statements
Examples of IF Expressions
1. This example assigns an arithmetic expression to VAR based on the condition
LENGTH > 0:
var := IF length > 0 THEN 10 ELSE 20;
2. This example nests an IF expression (in parentheses) within another expression:
var * index +
(IF index > limit THEN var * 2 ELSE var * 3)
3. This example nests an IF expression within another IF expression:
var := IF length < 0 THEN -1
ELSE IF length = 0 THEN 0
ELSE 1;