Conditional Directives Within a Free-Form Statement

You can use the /IF, /ELSEIF, /ELSE, and /ENDIF directives within any free-form statement other than a free-form calculation statement.

However, the following rules apply:
  • If a statement begins after an /IF, /ELSEIF, or /ELSE directive, the final semicolon for the statement must be specified before the next directive.
    The following code is not valid. The DSPLY statement begins after the /IF directive, so the semicolon for the DSPLY statement must appear before the /ELSE directive.
    
       /IF DEFINED(TRUE)
           DSPLY
       /ELSE
           print
       /ENDIF
             ('start');
    
  • If the /IF for a conditional group begins within a statement, the /ENDIF must be specified before the final semicolon for the statement.
The following is not valid because the /IF directive is specified after the DCL-S statement begins, and the /ENDIF directive appears after the final semicolon for the DCL-S statement.

   DCL-S name
     /IF DEFINED(TRUE)
       CHAR(10);
     /ELSE
       VARCHAR(10);
     /ENDIF