Conditional compilation directives in Cobol
About this task
COBOL compilation directives are special instructions evaluated by the compiler during compilation (not at runtime). They control the compilation process by specifying how the source code is handled and by determining which sections of code are included in or excluded from the final program.
Characteristics
Syntax: Begin with >> (double angle bracket)
Processing: Evaluated during compilation, before running the program
Scope: Affect compiler behavior, not runtime behavior
Supported directives
>>DEFINE- Defines compilation variables>>EVALUATE- Multi-way conditional compilation>>IF- Conditional compilation with branching
- Successive WHEN conditions enabling the same text
- Non-integer numerical values for compiler variables
Defining Variables
Internal Definition (in source code)
>>DEFINE PLAYERCOUNT AS 5
This defines a compilation variable named PLAYERCOUNT with value 5.
External Definition (outside source files)
If compilation variables are not defined in the source code, they can be specified externally in
the .dat file within the [PREPROCESSOR_DEFINITIONS] section using the
COBOL_DEFINES key.
[PREPROCESSOR_DEFINITIONS]
COBOL_DEFINES=PLAYERCOUNT="5";PARADEF=1;PLAYERCOUNT=3;ORD2=2;DEFI=4;WORD2=2;