pTAL Reference Manual (G06.24+, H06.09+, J06.03+)

IF array[a := a - 1] <> 0 THEN ... ;
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
The CASE expression selects one of several expressions.
selector
is an arithmetic expression [INT or INT(32)] that selects the expression to evaluate.
expression-1
is an expression of any data type. If you specify more than one expression-1, their data
types must be compatible.
expression-2
is an expression whose data type is compatible with the data type of expression-1. It is
evaluated if selector does not select an expression-1. If you omit the OTHERWISE
clause and an out-of-range case occurs, results are unpredictable.
All expressions in the CASE statement must have compatible data types:
Every data type is compatible with itself.
String and unsigned (1-16) data types are compatible with INT
Unsigned (17-32) data types are compatible with INT(32)
All fixed-point data types are compatible with each other; however, if expression-1 and
expression-2 are differently scaled fixed-point expressions, the data type of the IF
expression is the data type of the fixed-point expression whose scale factor is largest. The
smaller operand is implicitly scaled to match the type of the IF expression. For example, these
return statements are equivalent:
INT i; INT i;
FIXED(2) f2; FIXED(2) f2;
FIXED(3) f3; FIXED(3) f3;
FIXED(3) PROC p; FIXED(3) PROC p;
BEGIN BEGIN
RETURN IF i THEN f2 RETURN IF i THEN $SCALE(f2,1);
ELSE f3; ELSE f3;
END END
The compiler numbers the instances of expression-1 consecutively, starting with 0. If selector
matches the compiler-assigned number of an expression-1, that expression-1 is evaluated
and becomes the result of the CASE expression. If selector does not match a compiler-assigned
number, expression-2 is evaluated.
You can nest CASE expressions. CASE expressions resemble unlabeled CASE statements except
that CASE expressions select expressions rather than statements.
Example 14 (page 87) selects an expression based on the value of a and assigns it to x:
86 Expressions