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
Micro Focus conditional compilation line is encountered.
The Compiler defines constants that identify the type of compilation in effect; use these with the conditional compilation
commands. Each compilation produces a
__unix or
__windows constant, and a
__dotnet (for .NET COBOL),
__jvm (for JVM COBOL), or
__native constant, as appropriate.
Examples
An example of using
Micro Focus conditional compilation is provided in the topic
$IF Statement (Micro Focus Conditional Compilation).