COBOL Manual for TNS and TNS/R Programs
Procedure Division Verbs
HP COBOL Manual for TNS and TNS/R Programs—522555-006
9-87
Conditional Form
•
IF Sentences
A conditional IF statement followed by a period separator is called an “IF
sentence.” An IF sentence can contain IF statements (of either form) only if such IF
statements do not end with period separators.
•
Nested Conditional IF Statements
Conditional IF statements can be “nested” (included) within other conditional IF
statements. When conditional IF statements are nested, each optional ELSE
phrase is considered to be the next phrase of the nearest preceding unterminated
conditional IF statement with which that phrase is permitted to be associated
according to the syntax of the conditional IF statement, but with which no such
phrase has already been associated. An unterminated statement is one that has
not been previously terminated either explicitly or implicitly. The separator period
that terminates the sentence also terminates all nested statements.
•
How the Conditional IF Statement Works
The condition is evaluated. If its value is TRUE and NEXT SENTENCE is
specified (as opposed to statement-1 ), control passes to the next executable
sentence. The ELSE phrase, if present, is ignored.
If the value of condition is TRUE and statement-1 is specified (as opposed
to NEXT SENTENCE), statement-1 is executed. If control reaches the point
immediately following statement-1 (that is, statement-1 completes without
executing a GO TO statement or the equivalent), control passes to the end of the
IF statement. The ELSE phrase, if present, is ignored.
If the value of condition is FALSE and an ELSE phrase specifies NEXT
SENTENCE, control passes to the next executable sentence.
If the value of condition is FALSE and an ELSE phrase specifies
statement-2, statement-2 is executed. If control reaches the point
immediately following statement-2 (that is, statement-2 completes without
executing a GO TO statement or the equivalent), control passes to the end of the
IF statement.
If the value of condition is FALSE and there is no ELSE phrase, control passes
to the end of the IF statement.