IF

The IF directive provides for a one-way or two-way conditional compilation.

Format

Read syntax diagramSkip visual syntax diagram>>IFconstant-conditional-expression-1 text-1>>ELSEtext-2>>END-IF
>>IF, >>ELSE, >>END-IF
Must begin on a new line in area A or B and must be specified entirely on that line.
constant-conditional-expression-1
Must be formed in accordance with the constant conditional expression rules as described in Constant conditional expressions.
text-1, text-2

Must begin on a new line and may consist of multiple lines.

May be any kind of source lines, including compiler directives. text-1 or text-2 may also include COPY statements.

The phrases of a given IF directive must be specified all in the same library text or all in source text. For purposes of this rule, text-1 and text-2 are not considered phrases of the IF directive. A nested IF directive specified in text-1 or in text-2 is considered a new IF directive.

General Rules

  • text-1 and text-2 are not part of the IF compiler directive line. The text in the true branch of the IF directive (either text-1 or text-2) is subject to the matching and replacing rules of the COPY statement and REPLACE statement.
  • If constant-conditional-expression-1 evaluates to TRUE, all lines of text-1 are included in the resultant text and all lines of text-2 are omitted from the resultant text.
  • If constant-conditional-expression-1 evaluates to FALSE, all lines of text-2 are included in the resultant text and all lines of text-1 are omitted from the resultant text.

Related references  
COPY statement  
REPLACE statement