DEFINE
Use the DEFINE
compiler option to assign
a literal value to a compilation variable that is defined in the program
by using the DEFINE
directive with the PARAMETER
phrase.
The literal value provided for the compilation variable in the DEFINE
option
is sometimes referred to as a "parameter value" for the corresponding
compilation variable. Compilation variables can be used within any
of the conditional compilation directives, including DEFINE
, EVALUATE
,
and IF
. When a conditional compilation variable appears
in a conditional compilation directive, it is treated as a symbolic
reference to the literal value it currently represents.
The DEFINE
compiler option provides a way for you to assign values to
compilation variables from outside the program source. If that is not needed, it is sufficient to
use the DEFINE
directive within program source to define compilation variables.
Default is: NODEFINE
Abbreviations are: DEF
| NODEF
- compilation-variable-name-1
- The name of a compilation variable to be referenced in conditional compilation directives in the
program. If no corresponding
DEFINE
directive with PARAMETER phrase exists for compilation-variable-name-1 in the program, any instances of theDEFINE
compiler option specified for that compilation variable are ignored. compilation-variable-name-1 is formed according to the rules of a data-name user-defined word, except that DBCS characters are not allowed in the name. For details, see User-defined words in the COBOL for Linux® on x86 Language Reference. - literal-1
- The literal value that compilation-variable-name-1 will represent
symbolically in conditional compilation-related directives in the program.
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'). National literals, DBCS literals, and null-terminated alphanumeric literals (Z literals) are not supported.
- An integer literal.
- A boolean literal (only B'0' and B'1' are supported).
If literal-1 is not specified, a value of B'1' will be assigned to the compilation variable. For example, if you specify:>>define foo
foo
will be assigned the value B'1'.
- An equal sign (=) is interpreted to a left parenthesis, (
- A colon (:) is interpreted to a right parenthesis, )
- An underscore (_) is interpreted to a single quotation mark (')
You can add a backslash (\) escape character to prevent the interpretation and thus to pass characters in the strings. If you want the backslash (\) to represent itself (rather than as an escape character), use the double backslash (\\).
DEFINE(VAR1=1)
If VAR1
contains an equal sign, a colon, or an underscore that you want to escape from compiler's
interpretation, specify the DEFINE option as follows:DEFINE(VAR1\=1)
Multiple instances of the DEFINE
option can be specified to define a value for
multiple different compilation variables. If a single conditional compilation variable is defined
more than once, the last definition of the variable will be used as the value of the corresponding
conditional compilation variable. If NODEFINE
appears after previous instances of
the DEFINE
option, the definitions for all conditional compilation variables are
cancelled.
When DEFINE
options are specified in CBL statements, they can be used only on
the first program of a batch program. Therefore, if a file has multiple COBOL programs in it, there
can be CBL statements with DEFINE
options preceding the first program, but not the
other programs. The DEFINE
options specified for the first program (and DEFINE
options specified as cob2 command options) apply to all programs in a file.
Conditional compilation (COBOL for Linux on x86 Language Reference)
DEFINE (COBOL for Linux on x86 Language Reference)