pTAL Reference Manual (G06.24+, H06.09+, J06.03+)
IF i <> 1 THEN ! specified
BEGIN
label_b: ...
END;
END;
BEGIN:DISABLE_OVERFLOW_TRAPS
GOTO label_b; ! ERROR: Cannot branch between blocks
END; ! that have different trapping states
BEGIN
GOTO label_b; ! ERROR: Cannot branch from a BEGIN-END
END; ! block that does not specify a trapping
END; ! attribute to a BEGIN-END block that
! does
IF
The IF statement conditionally selects one of two statements to execute.
condition
is either:
• A conditional expression whose value has 16 bits
• An INT, INT(32), or FIXED arithmetic expression. If the result of the arithmetic expression
is not 0, condition is true. If the result is 0, condition is false.
statement-1
specifies the statement to execute if condition is true. statement-1 can be any statement
described in this section. If you omit statement-1, no action occurs for the THEN clause.
statement-2
specifies the statement to execute if condition is false. statement-2 can be any statement
described in this section.
If the condition is true, statement-1 executes. If the condition is false, statement-2
executes. If no ELSE clause is present, the statement following the IF statement executes.
Example 164 (page 217) compares two arrays.
Example 164 IF Statement
INT .new_array[0:9];
INT .old_array[0:9];
INT item_ok;
IF new_array = old_array FOR 10 WORDS THEN
item_ok := 1
ELSE
item_ok := 0;
You can nest IF statements to any level.
IF 217