pTAL Reference Manual (G06.24+, H06.09+, J06.03+)
You can nest IF expressions within an IF expression or within other expressions. The IF expression
resembles the IF (page 217) 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;
Group Comparison
The group comparison expression compares a variable with a variable or constant. With PVU
T9248AAD, you can compare any variable up to the current maximum allowed size for any object
of 127.5 megabytes.
var-1
is the identifier of a variable, with or without an index, that you want to compare to var-2,
constant, or constant-list. var-1 can be a simple variable, array, simple pointer,
structure, structure data item, or structure pointer, but not a read-only array.
relational-operator
is one of the following operators:
<, =, >, <=, >=, <>Signed relational operator
'<', '=', '>', '<=', '>=', '<>'Unsigned relational operator
All comparisons are unsigned whether you use a signed or unsigned operator.
var-2
is the identifier of a variable, with or without an index, to which var-1 is compared. var-2
can be a simple variable, array, read-only array, simple pointer, structure, structure item, or
structure pointer.
88 Expressions