pTAL Reference Manual (H06.08+)

Hardware Indicators
HP pTAL Reference Manual523746-006
13-12
Nesting Condition Code Tests
The first statement in an IF statements THEN clause or ELSE clause (or both) can, in
turn, be an IF statement that tests the condition code established by the conditional
expression of the containing IF statement. In this case, the root operator in the
containing IF statements conditional expression must be either:
A relational operator
i := i + 1;
IF i >= 0 THEN ! OK: >= is a relational operator
IF > THEN ...
An expression that consists only of a condition code
i := i + 1;
IF >= THEN ! OK: >= is a condition code
IF > THEN...
An IF statement that tests a hardware indicator cannot be labeled.
Nesting Condition Code Tests
You can test for more than one value of a condition code by nesting IF statements; for
example:
i := i + 1;
IF < THEN
...
ELSE IF = THEN
...
ELSE ! Must be >
...
INT PROC p;
BEGIN
CALL READX( ... );
IF < THEN RETURN -1
ELSE IF > THEN RETURN 1
ELSE RETURN 0;
END;
The following rules apply to nested IF statements:
Neither $OVERFLOW nor $CARRY can appear in the conditional expression of
any IF statement in a nest of IF statements.
i := i + 1;
IF > THEN
IF $OVERFLOW THEN ... ! ERROR: cannot test $OVERFLOW in
! nest of IF statements
i := i + 1;
IF $CARRY THEN ! ERROR: cannot test $CARRY in
IF > THEN ... ! nest of IF statements