An /IF group can contain at most one /ELSE directive./ELSEIF, and /ELSE are not valid outside an /IF group.Otherwise, the entire /IF group was not selected, so lines continue to be not selected. The following entries are used for /IF:įollowing the /ENDIF directive, if the matching /IF directive was a selected line, lines are unconditionally selected. The /IF compiler directive is used to test a condition expression for conditional compilation. Note: There is no practical limit to the nesting level of /IF groups. Testing ConditionsĬonditions are tested using /IF groups, consisting of an /IF directive, followed by zero or more /ELSEIF directives, followed optionally by an /ELSE directive, followed by an /ENDIF directive.Īny source lines except compile-time data, are valid between the directives of an /IF group. The condition expression is free-format but cannot be continued to the next line.
DEFINE COMPILING CODE CODE
* Specify code that is available in V4R4M0Ī condition expression has one of the following forms: * Specify code that is valid in V5R1M0 and subsequent releases Support for this condition is available starting with *V4R4M0 systems with the appropriate PTF installed. ENDIF Conditions Relating to the Target Release *VxRxMx This condition is defined if your program is being compiled for a version that is greater than or equal to the release in the condition, starting with *V4R4M0 (Version 4 Release 4 Modification 0).Use this condition if you will run the same program on different target releases, and want to take advantage of features that are not available in every release. * THIS_IS_MAIN is defined, the NOMAIN keyword will not * If the CRTRPGMOD command is not being used, or if * main procedure would define condition THIS_IS_MAIN before * This code might appear in a generic Control specification ENDIF *CRTRPGMOD This condition is defined if your program is being compiled by the CRTRPGMOD command, which creates a module. Conditions Relating to the Command Being Used *CRTBNDRPG This condition is defined if your program is being compiled by the CRTBNDRPG command, which creates a program. For example, for VisualAge RPG see VisualAge RPG Language Reference, SC09-2451-04. To learn what conditions are available with another version of the RPG IV compiler, consult the reference for the compiler. * compiler, the BNDDIR keyword might not be valid. * indicate where procedures can be found.
* the ILE RPG compiler, the BNDDIR keyword is used to * This module is to be defined on different platforms. Conditions Relating to the Environment *ILERPG This condition is defined if your program is being compiled by the ILE RPG IV compiler (the compiler described in this document). They can only be used with /IF and /ELSEIF. These conditions cannot be used with /DEFINE or /UNDEFINE. Several conditions are defined for you by the RPG compiler.
The entries in the condition-name area are free-format (do not have to be left justified). Use the /UNDEFINE directive to indicate that a condition is no longer defined. Note: The command parameter DEFINE can be used to predefine up to 32 conditions on the CRTBNDRPG and CRTRPGMOD commands /UNDEFINE (Positions 7-15) A subsequent /IF NOT DEFINED(condition-name) would be false. A subsequent /IF DEFINED(condition-name) would be true. The /DEFINE directive adds a condition-name to the list of currently defined conditions. The following entries are used for /DEFINE:
The /DEFINE compiler directive defines conditions for conditional compilation. The /EOF directive tells the compiler to ignore the rest of the source lines in the current source member.Ĭondition-names can be added to or removed from a list of currently defined conditions using the defining condition directives /DEFINE and /UNDEFINE.Testing condition directives, /IF, /ELSEIF, /ELSE and /ENDIF, control which source lines are to be read by the compiler.Condition expressions DEFINED(condition-name) and NOT DEFINED(condition-name) are used within testing condition /IF groups.Condition-names can be added or removed from a list of currently defined conditions using the defining condition directives /DEFINE and /UNDEFINE.The conditional compilation directive statements allow you to conditionally include or exclude sections of source code from the compile.