Pathway/iTS SCREEN COBOL Reference Manual (H06.10+, J06.03+)

Procedure Division
HP NonStop Pathway/iTS SCREEN COBOL Reference Manual426750-003
6-71
IF Statement
IF statements within IF statements are considered as paired IF and ELSE statements,
proceeding from left to right. An ELSE is assumed to apply to the immediately
preceding IF that has not already been paired with an ELSE.
The following conventions apply to the IF statement:
If
condition
is true,
statement-1
is run; if NEXT SENTENCE has been
substituted for
statement-1
, no operation is performed.
If
condition
is false,
statement-2
is run; if NEXT SENTENCE has been
substituted for
statement-2
or if the ELSE clause has been omitted, no
operation is performed.
If a GO TO statement that causes a transfer of control is run as part of
statement-1
or
statement-2,
control is unconditionally transferred to the
target of the GO TO statement.
If control is not unconditionally transferred by execution of a GO TO statement as
part of
statement-1
or
statement-2,
control passes to the next executable
statement following the IF statement after all statements run as part of the IF
statement have completed.
Comparisons (using GREATER THAN, LESS THAN, EQUAL, and so on) of a
PIC N data item or literal with a numeric data item (PIC 9) are not allowed. All
other comparisons are allowed and are done on a byte-by-byte basis.
The following example illustrates a simple IF statement:
IF julian-days IS GREATER THAN 59,
ADD leap-year TO julian-days.
The following example illustrates a simple IF ELSE statement:
IF tally GREATER THAN 0
MOVE 0 TO tally
MOVE 3 TO msg-index
PERFORM print-error-routine
ELSE
MOVE 1 TO flag.
The following example illustrates nested IF statements:
IF employee-number NOT EQUAL TO SPACES
PERFORM read-routine
IF no-error
PERFORM list-record-out
IF yes
PERFORM delete-master
IF no-error
ADD 1 TO delete-count
ELSE
NEXT SENTENCE
ELSE
MOVE 0 TO flag
ELSE