A $IF statement provides the means whereby selected parts of the source text are not included in the compilation.
General Formats for Format 1
General Formats for Format 2
General Formats for Format 3
Syntax Rules
Constant-name-1 is defined by a level 78 entry or a CONSTANT Compiler directive.
If literal-1 is numeric, it must be zero or a positive integer.
Directive-setting is specified in the same format as it is given in a $SET statement and may be preceded by NO. However, the format used in the $IF statement differs from the format used in the $SET statement as follows:
No spaces are permitted between the NO and directive name
Hyphens in the directive must be specified exactly
If the directive has a parameter it may be omitted
Only directives used in the syntax-check phase and produced in the directive settings list (see compiler directive SETTINGS) may be specified for directive-setting
The whole statement must appear on a single line.
$IF can be nested within another $IF.
General Rules
Constant-name-2 is DEFINED if it is the subject of a level 78 entry or a CONSTANT Compiler directive, otherwise it is NOT DEFINED.
Directive-setting SET evaluates true if the given setting matches the actual directive setting. If a parameter is specified then it must also match.
The comparison between Directive-setting and the actual directive setting is not case sensitive.
If the condition evaluates true the source lines following the $IF statement are processed. If the condition evaluates false, COBOL source lines are ignored until the next conditional compilation line is encountered.
Examples
An example of using conditional compilation is provided in the topic $IF Statement (Conditional Compilation).