COBOL Manual for TNS/E Programs (H06.08+, J06.03+)

IF and IFNOT
IF
enables compilation of subsequent source text if the toggle with toggle-number is set;
disables it otherwise.
IFNOT
suppresses compilation of subsequent source text if the toggle with toggle-number is set;
enables it otherwise.
toggle-number
is an integer in the range 1 through 15.
NoneDefault:
Must be either on a directive line of its own or be the last of a sequence of directivesPlacement:
Requires a preceding IF or IFNOT directive with the same toggle-numberDependencies:
IF and IFNOTReferences:
The toggles are turned on and off by use of the SETTOG and RESETTOG directives. If no SETTOG
directive has been issued, a toggle is off.
COPY and REPLACE statements are not affected by this directive; they are still processed and
expanded. In contrast, a SOURCE directive is ignored when it is part of the ignored text.
If a given toggle is not set, any directives between an IF for that toggle and its subsequent ENDIF
are parsed but are not acted upon; if a given toggle is set, any directives between an IFNOT for
that toggle and its subsequent ENDIF are parsed but are not acted upon.
Example 154 IF Directive
?IF 1
ADD A B C GIVING D
?ENDIF 1
?IFNOT 1
COMPUTE D = A + B + C
?ENDIF 1
In Example 154, if toggle 1 is turned on, the ADD statement is compiled; if toggle 1 is turned off,
the COMPUTE statement is compiled.
NOTE: The IFNOT directive does not behave like an ELSE clause of the IF directive. Each IF and
each IFNOT must have its own ENDIF directive.
Compiler Directives 553