pTAL Reference Manual (G06.24+, H06.09+, J06.03+)
a := a + 1;
END;
IF $CARRY THEN ... ! ERROR: intervening END is invalid
CALL WRITEREAD(...);
firstchar := str_buff;
IF <= THEN... ! ERROR: intervening assignment
! statement is invalid
CALL WRITEREAD(...);
IF < THEN ... ! ERROR: previous statement does not
! set condition code
• Be part of a nest of IF statements as described in Nesting Condition Code Tests (page 242)
The hardware indicator in the conditional expression of an IF statement must be the first operand
in the expression.
IF $CARRY THEN ... ! OK: hardware indicator is
! first operand
IF <= OR a >= 99 THEN ... ! OK: hardware indicator is
! first operand
IF I <= 999 AND > THEN ... ! ERROR: condition code must be
! first operand
IF a = b OR $CARRY THEN ... ! ERROR: $CARRY must be
! first operand
IF a = b OR $OVERFLOW THEN ... ! ERROR: $OVERFLOW must be
! first operand
The first statement in an IF statement’s 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 statement’s 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;
242 Hardware Indicators