DEFINE

The DEFINE directive defines or undefines a compilation variable. The compilation variables can be used within any of the conditional compilation directives (DEFINE, EVALUATE, and IF). The compilation variable is treated as a symbolic reference to the literal value it currently represents.

Format

Read syntax diagramSkip visual syntax diagram>>DEFINEcompilation-variable-name-1AS arith-expr-1literal-1PARAMETEROVERRIDEOFF
>>DEFINE
Must begin on a new line in area A or B and must be specified entirely on that line.
compilation-variable-name-1
Must not be the same as a conditional compiler directive keyword and must not be one of the predefined compilation variable names.

If a DEFINE directive does not specify the OFF or the OVERRIDE phrase, then one of the following conditions must be true:

  • compilation-variable-name-1 was not declared previously within the same compilation group.
  • The previous DEFINE directive referring to compilation-variable-name-1 must have been specified with the OFF phrase.
  • The previous DEFINE directive referring to compilation-variable-name-1 must have specified the same value.
literal-1
Must be one of the following items:
  • An alphanumeric literal, which can be specified as a regular alphanumeric literal ('abcd') or as a hex literal (x'F1F2F3'). Start of changeNational literals, DBCS literals, and null-terminated alphanumeric literals (Z literals) are not supported. End of change
  • An integer literal.
  • A boolean literal (only B'0' and B'1' are supported).
arith-expr-1
Must be formed in accordance with the arithmetic expression rules as described in Compile-time arithmetic expressions.

General rules

  • DEFINE directives that appear in code that is omitted as the result of other conditional compilation directives are not processed.
  • In the text that follows a DEFINE directive that defines compilation-variable-name-1 and does not include the OFF phrase, compilation-variable-name-1 can be used in a conditional compilation directive wherever a literal of the category associated with the name is permitted, including in a defined condition and a boolean condition.
  • In the text that follows a DEFINE directive specifying compilation-variable-name-1 with the OFF phrase, compilation-variable-name-1 can be used only in a defined condition, unless compilation-variable-name-1 is redefined in a subsequent DEFINE directive without the OFF phrase.
  • If the OVERRIDE phrase is specified, compilation-variable-name-1 is unconditionally set to reference the value of the specified operand.
  • If the AS PARAMETER phrase is specified, the value referenced by compilation-variable-name-1 is obtained from a DEFINE option for compilation-variable-name-1, if such an option exists. If there is no DEFINE option for compilation-variable-name-1, compilation-variable-name-1 is not defined.
  • If arith-expr-1 is specified, arith-expr-1 is evaluated according to Compile-time arithmetic expressions, and compilation-variable-name-1 references the resultant value.
  • If literal-1 is specified, compilation-variable-name-1 references literal-1.

Related references  
Defined conditions  
Predefined compilation variables  
DEFINE (Enterprise COBOL Programming Guide)