pTAL Reference Manual (H06.03+)
Hardware Indicators
HP pTAL Reference Manual—523746-005
13-13
Nesting Condition Code Tests
You cannot test $OVERFLOW or $CARRY to determine if an overflow or carry
occurred while evaluating an IF statement’s conditional expression.
IF i + 1 < 100 THEN
BEGIN
IF $CARRY THEN ... ! ERROR: invalid to test $CARRY here
END
You can test $OVERFLOW or $CARRY by evaluating, in a separate assignment
statement, the expression in which overflow or carry could occur, then test
$OVERFLOW or $CARRY.
INT temp;
temp := i + 1; ! Carry could occur here
IF NOT $CARRY THEN ! OK to test $CARRY here
BEGIN
IF temp < 100 THEN ...
END
ELSE ... ! Handle $CARRY condition
•
Except as noted in the following item, the conditional expression in each IF
statement in a nest of IF statements can test only the value of the condition code,
optionally preceded by the NOT operator. The conditional expression cannot
include any other operator or operand.
i := i + 1;
IF <= THEN
IF NOT = THEN ... ! OK
•
The conditional expression of the innermost IF statement can be a complex
expression, but the condition code must be the first operand in the expression.
i := j + 1;
IF >= THEN
IF = AND (j + 4) / 5 * 5 > 0 THEN ... ! OK
•
If the root operator in the conditional expression of an IF statement is a relational
operator, the first statement in the THEN or ELSE clause of the IF statement can
be an IF statement that tests the condition code set by the root operator of the
encompassing IF statement.
IF (i + 10) <= (m - 2) THEN ! Root operator (<=) is
BEGIN ! relational operator
IF < THEN ! OK: test if condition was
... ! "less than"
ELSE
END;
IF (i < -1) OR (i > 1) THEN
BEGIN
IF < THEN ! ERROR: root operator of IF
... ! statement is Boolean,
END; ! not relational










