Compiler-directing statements control the processing of a compilation
group. The following compiler-directing facilities are provided:
- Compiler-directing statements for specifying source text manipulation
-
Compiler directives for specifying standard
compilation options
The BASIS mechanism
The ++INCLUDE/ -INC mechanisms
Conditional compilation
The listing control statements
Compiler directives that specify
options specific to your
COBOL system
Source text manipulation allows you to include text from one or more
COBOL source libraries in your program. COBOL source libraries are collections
of source text that programmers can use in many different programs, reducing
effort and promoting consistency between programs. Any suitable source text
editor can be used to create the source text.
You use the COPY statement to include source text from a library in
your program. The effect of the COPY statement is to insert text into the
compilation group, where it is treated by the COBOL system as part of the
compilation group. All occurrences of a given literal, identifier, word or
group of words in the library text can be replaced with alternative text during
the copy process.
Source text manipulation also allows you to
replace source text in your program. You use the REPLACE statement to replace
source text. The effect of the REPLACE statement is to replace source text in
your program by new text supplied in the REPLACE statement; the COBOL system
treats the new text as part of the compilatiion group.
Function
The COPY statement incorporates text into a COBOL compilation group.
Examples
Examples of the following are provided in the chapter Examples
in your Language Reference - Additional Topics:
General Format
Directives
- In addition to Compiler directives which provide flagging and modify
the reserved word list, the following directives may impact either the syntax
or the semantics described in this section.
- COPYEXT - specifies the filename extension to be used for
locating copy files.
- COPYLBR - specifies that library-names are equivalent to
.lbr files.
- COPYLIST - causes the result of a
COPY statement to
be included in the listing file.
- FOLD-COPY-NAME - allows the
Compiler to find a
copy library member when the library name on disk and the text-name in the COPY
statement do not use the same upper-case and lower-case letters for the library
member name.
- OLDCOPY - changes the handling of COPY statements to match the
ANS'68 and OS/VS COBOL LANGLVL(1) rules.
Syntax Rules
- If more than one COBOL library is available while the source is
passed through the COBOL system, text-name must be qualified by the
library-name identifying the COBOL library in which the text associated with
text-name resides. See your COBOL system documentation for details of
libraries.
This restriction is removed.
- The COPY statement must be preceded by a space and terminated by the
separator period.
- Pseudo-text-1 must not be
null, nor can it consist solely of either the character space(s) or comment
lines.
- Pseudo-text-2 can be null.
- Character-strings within pseudo-text-1 and pseudo-text-2 can be
continued. However, both characters of a pseudo-text delimiter must be on the
same line. (See the section
Continuation of
Lines in the chapter
Language
Fundamentals.)
- Word-1 or word-2 can be any single COBOL word.
- A COPY statement can occur in the compilation group anywhere a
character-string or a separator can occur except that a COPY statement must not
occur within another COPY statement.
- Text-name defines a unique external file-name which conforms to the
rules for user-defined words.
External-file-name-literal is an alphanumeric
literal that conforms to the operating system rules for file-names. It can be
specified with or without enclosing quotation marks.
Text-names and unquoted external-file-name-literals are always
converted to upper case.
-
Library-name-literal is an alphanumeric literal
that conforms either to the operating system rules for file-names or to the
operating system rules for device identifiers. It can be specified with or
without enclosing quotation marks.
Library-name-literals not inside quotation
marks are always converted to upper case.
-
The SUPPRESS phrase is used to suppress the printing of the
contents of the copy member on the source listing.
-
If the word COPY appears in a comment-entry or in
the place where a comment entry can appear, it is considered part of the
comment-entry.
A COPY statement that appears in a comment-entry
is processed.
-
External-file-name-literal and
library-name-literal, when enclosed in quotation marks, may contain the $, #,
and @ characters.
Partial-word-1 must consist of one text word.
Partial-word-2 must consist of zero or one text
word.
Neither a nonnumeric literal nor a national
literal can be specified as partial-word-1 or partial-word-2.
- Library text must
conform to the rules for COBOL reference format.
General Rules
- The compilation of a compilation group containing COPY statements is
logically equivalent to the processing of all COPY statements before
the processing of the resultant compilation group.
- The effect of processing a COPY statement is that the library text
associated with text-name is copied into the source text, logically replacing
the entire COPY statement, beginning with the reserved word COPY and ending
with the punctuation character period, inclusive.
- If the REPLACING phrase is not specified, the library text is copied
unchanged.
If the REPLACING phrase is specified, the library text is copied and
each properly matched occurrence of pseudo-text-1, identifier-1, literal-1,
word-1 and partial-word-1 in the library text is replaced by the corresponding
pseudo-text-2, identifier-2, literal-2, word-2 or partial-word-2.
- For purposes of matching, identifier-1, literal-1 and word-1 are
treated as pseudo-text containing only identifier-1, literal-1 or word-1,
respectively.
- The comparison operation to determine text replacement occurs in the
following manner:
- The leftmost library text word which is not a separator comma or
a separator semicolon is the first text word used for comparison. Any text word
or space preceding this text word is copied into the source text. Starting with
the first text word for comparison and first pseudo-text-1, identifier-1,
word-1, literal-1 or partial-word-1 that was specified in the REPLACING phrase,
the entire REPLACING phrase operand that precedes the reserved word BY is
compared to an equivalent number of contiguous library text words.
- Pseudo-text-1, identifier-1, word-1, or literal-1 match the
library text if, and only if, the ordered sequence of text words that forms
pseudo-text-1, identifier-1, word-1, or literal-1 is equal, character for
character, to the ordered sequence of library text words.
-
When the LEADING phrase is specified,
partial-word-1 matches the library text only if the contiguous sequence of
characters that forms partial-word-1 is equal, character for character, to an
equal number of contiguous characters starting with the leftmost character
position of a library text-word. When the TRAILING phrase is specified,
partial-word-1 matches the library text only if the contiguous sequence of
characters that forms partial-word-1 is equal, character for character, to an
equal number of contiguous characters, ending with the rightmost character
position of a library text-word.
- The following rules apply for the purpose of matching:
- Each occurrence of a separator comma, semicolon, or space in
pseudo-text-1 or in the library text is considered to be a single space. Each
sequence of one or more space separators is considered to be a single space.
- Except when used in nonnumeric or national literals, each
lower-case letter is equivalent to the corresponding upper-case letter as
specified for the COBOL character set.
- Text words within a debugging line participate in the
matching as if the "D" did not appear in the indicator area.
- If no match occurs, the comparison is repeated with each next
successive pseudo-text-1, identifier-1, word-1, literal-1, or pseudo-text-1, if
any, in the REPLACING phrase until either a match is found or there is no next
successive REPLACING operand.
- When all the REPLACING phrase operands have been compared and no
match has occurred, the leftmost library text word is copied into the source
text. The next successive library text word is then considered as the leftmost
library text word, and the comparison cycle starts again with the first
pseudo-text-1, identifier-1, word-1, literal-1, or partial-word-1 specified in
the REPLACING phrase.
- Whenever a match occurs between pseudo-text-1, identifier-1,
word-1, or literal-1 and the library text, the corresponding pseudo-text-2,
identifier-2, word-2, or literal-2 is placed into the source text.
When a match occurs between partial-word-1
and the library text-word, the library text-word is placed into the resultant
text with the matched characters either replaced by partial-word-1 or deleted
when partial-word-2 consists of zero text-words.
The library text word immediately following the rightmost text
word that participated in the match is then considered as the leftmost text
word. The comparison cycle starts again with the first pseudo-text-1,
identifier-1, word-1, literal-1 or partial-word-1 specified in the REPLACING
phrase.
- The comparison operation continues until the rightmost text word
in the library text has either participated in a match or been considered as a
leftmost library text word and participated in a complete comparison cycle.
- A comment line occurring in either the library text or pseudo-text-1
is interpreted, for purposes of matching, as a single space. Comment lines
appearing in either pseudo-text-2 or library text are copied into the source
text unchanged.
- The text produced as a result of the complete processing of a COPY
statement must not contain a COPY statement.
This text can contain a COPY statement provided
neither this contained COPY nor the already expanded COPY includes the
REPLACING phrase. However, recursive COPY statements (where a library-text is
referred to by a COPY statement within it) are not allowed.
COPY statements may be nested in this way to any
level. One of the COPY statements in this structure may include the REPLACING
phrase, and the replacements specified
are in effect for
all subsidiary COPY statements.
- The syntactic correctness of the library text cannot be independently
determined.
Except for COPY statements,
the syntactic correctness of the entire COBOL compilation group
cannot be determined until all COPY statements have been completely processed.
-
If the REPLACING phrase is specified, the
library text must not contain an EXEC HTML statement. Violation of this rule
may result in unexpected behavior and syntax errors.
- Each text word copied from the library but not replaced, or only
partially replaced, is copied so as to start in the same area of the line in
the resultant source text as it begins in the line within the library. However,
if a text word copied from the library begins in area A but follows another
text word, which also begins in area A of the same line, and if replacement of
a preceding text word in the line by replacement text of greater length occurs,
the following text word begins in area B if it cannot begin in area A. Each
text word in pseudo-text-2 that is to be placed into the resultant source text
begins in the same area of the resultant source text as it appears in
pseudo-text-2. Each identifier-2, literal-2, and word-2 that is to be placed
into the resultant source text begins in the same area of the resultant source
text as the leftmost library text word that participated in the match would
appear if it had not been replaced.
If additional lines are introduced into the source text as a result
of a COPY statement, each text word introduced appears on a debugging line if
the copy statement begins on a debugging line, or if the text word being
introduced appears on a debugging line in library text. When a text word
specified in the BY phrase is introduced, it appears on a debugging line if the
first library text word being replaced is specified on a debugging line. Except
in the preceding cases, only those text words that are specified on debugging
lines where the debugging line is within pseudo-text-2 appear on debugging
lines in the resultant source text. If any literal specified as literal-2 or
within pseudo-text-2 or library text is of too great a length to be
accommodated on a single line without continuation to another line in the
resultant source text and the literal is not being placed on a debugging line,
additional continuation lines are introduced which contain the remainder of the
literal. If replacement requires that the continued literal be continued on a
debugging line, the compilation group is in error.
- For purposes of compilation, text-words after replacement are placed
in the source text according to the rules for reference format as described in
the section
Reference Format in
the chapter Language Fundamentals.
- If the unit identifier is not explicitly specified, the default drive
is used. (The
default is operating system-dependent.)
-
The OLDCOPY Compiler directive causes the entire
entry to be replaced by the information identified by text-name, except that
the data-name preceding the COPY statement replaces the corresponding data-name
in the text-name.
-
If certain conventions are followed in library
text, parts of names, for example the prefix portion of data-names, can be
changed with the REPLACING phrase.
To use this type of "partial word
replacement" the portion of the words to be modified must be enclosed
in one of the following
ways:
- In pairs of left and right parentheses. For example, (ABC)
- Within colons. For example :XYZ:
Note: The LEADING and TRAILING phrases can also be used for
partial word replacement. The LEADING and TRAILING phrases are supported by the
MF dialect and the next COBOL standard, however, they are not included in the
ANSI '85 COBOL standard.
Function
The REPLACE statement modifies source text in a compilation group.
General Formats
Format 1
Format 2
Syntax Rules
- A REPLACE statement can be specified anywhere in source text or in
library text that a character-string or a separator, other than the closing
delimiter of a literal, can appear. It must be preceded by a separator space
except when it is the first statement in a compilation group.
- A REPLACE statement must be terminated by a separator period.
- Pseudo-text-1 must contain one or more text words.
- Pseudo-text-2 can contain zero, one, or more text words.
- Character-strings within pseudo-text-1 and pseudo-text-2 can be
continued.
- A text word within pseudo-text must be between 1 and 322 characters
long.
- Pseudo-text-1 must not consist entirely of a separator comma or a
separator semicolon.
- If the word REPLACE appears in a comment-entry or in the place where
a comment-entry can appear, it is considered part of the comment-entry.
Partial-word-1 must consist of one text-word.
Partial-word-2 must consist of zero or one
text-word.
Neither a nonnumeric literal nor a national
literal can be specified as partial-word-1 or partial-word-2.
General Rules
- Pseudo-text-1 specifies the source text to be replaced by
pseudo-text-2.
Partial-word-1 specifies the text to be
replaced by partial-word-2.
- The Format 2 REPLACE statement specifies that any text replacement
currently in effect is discontinued.
- A given occurrence of the REPLACE statement is in effect from the
point at which it is specified until the next occurrence of the REPLACE
statement or the end of the compilation unit, respectively.
- Any REPLACE statements contained in a source unit are processed after
the processing of any COPY statements contained in that source unit.
- The text produced as a result of the processing of a REPLACE
statement must contain neither a COPY statement nor a REPLACE statement.
- The comparison operation to determine text replacement begins with
the text immediately following the REPLACE statement and occurs in the
following manner:
- Starting with the leftmost source text word and the first
pseudo-text-1 or partial-word-1, pseudo-text-1 or partial-word-1 is compared to
an equivalent number of contiguous source text words.
- Pseudo-text-1 matches the source text if, and only if, the order
sequence of text words that forms pseudo-text-1 is equal, character for
character, to the ordered sequence of source text words.
When the LEADING phrase is specified,
partial-word-1 matches the source text-word only if the contiguous sequence of
characters that forms partial-word-1 is equal, character for character, to an
equal number of contiguous characters starting with the leftmost character
position of that source text-word. When the TRAILING phrase is specified,
partial-word-1 matches the source text-word only if the contiguous sequence of
characters that forms partial-word-1 is equal, character for character, to an
equal number of contiguous characters, ending with the rightmost character
position of that source text-word.
- The following rules apply for the purpose of matching:
- Each occurrence of a separator comma, semicolon, or space in
pseudo-text-1 or in the source text is considered to be a single space. Each
sequence of one or more space separators is considered to be a single space.
- Except when used in nonnumeric or national literals, each
lower-case letter is equivalent to the corresponding upper-case letter as
specified for the COBOL character set.
- Text words within a debugging line participate in the
matching as if the "D" did not appear in the indicator area.
- If no match occurs, the comparison is repeated with each next
successive occurrence of pseudo-text-1 or partial-word-1, until either a match
is found or there is no next successive occurrence of pseudo-text-1 or
partial-word-1.
- When all occurrences of pseudo-text-1 or partial-word-1 have
been compared and no match has occurred, the next successive source text-word
is then considered as the leftmost source text-word, and the comparison cycle
starts again with the first occurrence of pseudo-text-1 or partial-word-1.
- Whenever a match occurs between pseudo-text-1 and the source
text, the corresponding pseudo-text-2 replaces the matched text in the source
text.
When a match occurs between partial-word-1
and the source text-word, the matched characters of that source text-word are
either replaced by partial-word-2 or deleted when partial-word-2 consists of
zero text-words.
The source text word immediately following the rightmost text
word that participated in the match is then considered as the leftmost source
text word. The comparison cycle starts again with the first occurrence of
pseudo-text-1 or partial-word-1.
- The comparison operation continues until the rightmost text word
in the source text which is within the scope of the REPLACE statement has
either participated in a match or been considered as a leftmost source text
word and participated in a complete comparison cycle.
- Comment lines or blank lines occurring in either the source text or
pseudo-text-1 are ignored for purposes of matching; and the sequence of text
words in the source text and in pseudo-text-1 is determined by the rules for
reference format. See the section
Reference Format
Representation in the chapter
Language
Fundamentals. Comment lines or blank lines in pseudo-text-2 are
placed into the resultant source text unchanged whenever pseudo-text-2 is
placed into the source text as a result of text replacement. A comment line or
blank line in source text is not placed into the resultant source text if that
comment line or blank line appears within the sequence of text words that match
pseudo-text-1.
- Only after all COPY and REPLACE statements have been completely
processed, can the syntactical correctness of the rest of the source code be
determined.
- Text words inserted into the source text as a result of processing a
REPLACE statement are placed in the source text according to the rules for
reference format. See the section
Reference Format in
the chapter Language
Fundamentals. When inserting text words of pseudo-text-2 into the
source text, additional spaces can be introduced only between text words where
a space (including the assumed space between source lines) already exists.
- If additional lines are introduced into the source text as a result
of the processing of REPLACE statements, the indicator area of the introduced
lines contains the same character as the line on which the text being replaced
begins, unless that line contains a hyphen, in which case the introduced line
contains a space.
If any literal within pseudo-text-2 is of a length too great to be
accommodated on a single line without continuation to another line in the
resultant source text and the literal is not being placed on a debugging line,
additional continuation lines are introduced to contain the remainder of the
literal. If replacement requires the continued literal to be continued on a
debugging line, the compilation unit is in error.
-
The source text for which a REPLACE statement
is in effect must not contain an EXEC HTML statement. Violation of this rule
may result in unexpected behavior and syntax errors.

A compiler directive specifies options or compilation variables for use
by the compiler.
General Format
>>compiler-instruction
Syntax Rules
- A compiler directive must be specified on one line, except for the
EVALUATE and the IF directives for which
there are specific
rules.
- A compiler directive must be preceded only by zero, one, or more
space characters.
- When the reference format is fixed format, a compiler directive
must be specified
in the program-text area and may be followed only by space characters.
- When the reference format is free
format, a compiler
directive can be followed only by space characters and an optional in-line
comment.
- A compiler directive is composed of the two contiguous COBOL
characters >>, optionally followed by the COBOL character space, followed
by compiler-instruction. >>
is treated as
though it were followed by a space if no space is specified after >>.
- Compiler-instruction is composed of the compiler-directive words
defined in the specific syntax for each directive.
- A compiler-directive word is reserved within the context of the
compiler directive in which it is specified and may be used elsewhere as any
type of COBOL word.
- A compiler directive can be specified anywhere in a compilation group
except
- As restricted by the rules for the specific compiler directive,
- Within a source text manipulation statement,
- Between the lines of a continued character string,
- On a debugging line.
- Compiler directive lines can be specified within library text.
- A literal in a compiler directive must not be specified as a
concatenation expression or a figurative constant.
General Rules
- A compiler directive is treated as a single blank line during the
matching operation of a COPY or REPLACE statement. A directive will not match
any pseudo-text or partial-word and therefore
is not affected by
the replacing action.
- A compiler directive is processed before, during, or after the
processing of COPY and REPLACE statements as indicated in the specific rules
for each directive.
- The compiler directives >>EVALUATE, and >>IF, when
specified in the source-text of >>IF and >>EVALUATE directives
take effect when
encountered during conditional compilation. All other compiler directives are
processed when the source code resulting from conditional compilation is
processed.
The use of certain compiler directives provides a means of including or
omitting selected lines of source code. This is called conditional compilation.
The compiler directives that are used for conditional compilation are the
EVALUATE directive and the IF directive. The EVALUATE and IF directives are
used to select lines of code that are to be compiled or are to be omitted
during compilation.
An arithmetic expression can be specified in the EVALUATE directive and
in a constant conditional expression. The formation, the order of precedence,
and the rules for evaluation of these arithmetic expressions are shown in
the section
Arithmetic
Expressions in the chapter Procedure Division. The following
addition rules apply:
- All operands must be fixed-point numeric literals or arithmetic
expressions in which all operands are fixed-point numeric literals.
Note: This includes constants that are equated to a
fixed-point numeric literal.
- After each arithmetic operation, the result is truncated to the
integer part of the value and the resultant value is considered to be an
integer.
- After the arithmetic expression is evaluated, the resulting value is
considered to be a numeric literal.
- An arithmetic expression must not result in a size error
condition.
A constant conditional expression is a conditional expression in which
all the operands are literals or arithmetic expressions containing only literal
terms. A special form of condition known as a defined condition may also be
used as part of a constant conditional expression.
Syntax Rules
- A constant conditional expression must be one of the following:
- A simple relation condition in which both operands are either
literals or arithmetic expressions containing only literal terms and which is
formed according to the rules in
the section Relation Condition
in the chapter Procedure Division. The following rules also apply:
- The operands on both sides of the relational operator must be
the same category. An arithmetic expression is of the category numeric.
- If literals are specified and they are not numeric literals,
the relational operator must be "IS [ NOT ] EQUAL TO" or "IS [
NOT ] =".
- A defined condition.
- A complex condition as specified in
the section Complex Conditions
in the chapter Procedure Division
which is formed by
combining the above forms of simple conditions into complex conditions.
Abbreviated combined relation conditions must not be specified.
General Rules
- Complex conditions are evaluated according to the rules in
the section Complex Conditions
in the chapter Procedure Division.
- For a simple relation condition where the operands are not numeric,
no collating sequence is used for the comparison. A character by character
comparison for equality is used.
Note: This means that upper-case and lower-case letters are not
equivalent.
General format
compilation-variable-name-1 IS [ NOT ] DEFINED
General Rules
- A defined condition using the IS DEFINED syntax evaluates TRUE if
compilation-variable-name-1 is currently defined.
- A defined condition using the IS NOT DEFINED syntax evaluates TRUE if
compilation-variable-name-1 is not currently defined.
The EVALUATE directive provides for multi-branch conditional
compilation.
General Format
Format 1
Format 2

Syntax Rules
All Formats
- Each pair of contiguous COBOL characters >> and the succeeding
compiler-directive words and operands up to, but not including, source-text-1
and source-text-2 must be specified on a new line and be specified entirely on
that line. The first text-word of source-text-1 and the first text-word of
source-text-2 must each begin on a new line.
- Source-text-1 and source-text-2 can be any kind of source text,
including compiler directives. Source-text-1 and source-text-2 can span
multiple lines.
Format 1
- All operands of one EVALUATE directive must be of the same category.
For this rule, an arithmetic expression is of category numeric.
- If the THROUGH phrase is specified, all selection subjects and
selection objects must be of category numeric.
- The words THROUGH and THRU are equivalent.
General Rules
All Formats
- The EVALUATE directive is processed during the processing of COPY and
REPLACE statements.
Format 1
- Literal-1 or arithmetic-expression-1, referred to as the selection
subject, is compared against the values specified in each WHEN phrase in turn
as follows:
- If the THROUGH phrase is not specified, a TRUE result is returned
if the selection subject is equal to literal-2 or arithmetic-expression-2.
- If the THROUGH phrase is specified, a TRUE result is returned if
the selection subject lies in the inclusive range determined by literal-2 or
arithmetic-expression-2 and literal-3 or arithmetic-expression-3.
As soon as a WHEN phrase is found that yields a TRUE result, the
associated source-text-1 is compiled and all remaining lines up to and
including the >>END-EVALUATE line are ignored. If no WHEN phrase yields a
TRUE result, the source-text-2 associated with the >>WHEN OTHER phrase,
if specified, is compiled.
Format 2
- For each WHEN phrase in turn, the constant-conditional-expression is
evaluated.
As soon as a WHEN phrase is found that yields a TRUE result, the
associated source-text-1 is compiled and all remaining lines up to and
including the >>END-EVALUATE line are ignored. If no WHEN phrase yields a
TRUE result, the source-text-2 associated with the >>WHEN OTHER, if
specified, is compiled.
The IF directive provides for one-way or two-way conditional
compilation.
General Format
>>IF constant-conditional-expression-1 [source-text-1]
[ >>ELSE [source-text-2] ]
>>END-IF
Syntax Rules
- Each pair of contiguous COBOL characters >> and the succeeding
compiler-directive words and operands up to, but not including, source-text-1
and source-text-2 must be specified on a new line and be specified entirely on
that line. The first text-word of source-text-1 and the first text-word of
source-text-2 must each begin on a new line.
- Source-text-1 and source-text-2 may be any kind of source text,
including compiler directives. Source-text-1 and source-text-2 may span
multiple lines.
General Rules
- The IF directive is processed during the processing of COPY and
REPLACE statements.
- If constant-conditional-expression-1 evaluates to TRUE, then
source-text-1 is compiled as part of the source text, and source-text-2 is
ignored.
- If constant-conditional-expression-1 evaluates to FALSE, then
source-text-1 is ignored and source-text-2, if specified, is compiled as part
of the source text.
The REPOSITORY directive specifies whether information is added to the
external repository. It also specifies whether prototypes and definitions are
checked against the interface information in the external repository.
General Format

Directives
- In addition to the Compiler directives which provide flagging and
modify the reserved word list, the following directives may impact either the
syntax or the semantics described in this section.
- RDFPATH - specifies the location of the library for the
repository files.
Syntax Rules
- The REPOSITORY directive must be specified only before the first
Identification Division of a compilation unit and must not be specified within
a compilation unit.
- The REPOSITORY directive applies to the remainder of the compilation
group or until another REPOSITORY directive is encountered.
General Rules
- If no REPOSITORY
directive is specified, the result is as if the directive had been specified
as:
>>REPOSITORY UPDATE OFF WITH CHECKING.
- If the ON phrase is specified explicitly or implicitly, the
information for a compilation unit is added to the external repository before
the next compilation unit is compiled or at the end of the compilation group if
there is no next compilation unit.
- If the OFF phrase is specified, the external repository is not
updated by the compiler.
- If the CHECKING phrase is specified, a warning mechanism flags a
class-definition or interface-definition that differs from the information
about that source unit in the external repository. Details on the information
in the external repository are specified in
the section
External Repository
in the chapter Language Fundamentals.
The BASIS mechanism provides support to allow an entire COBOL source
file to be non-interactively edited, temporarily, and the result of this edit
to be submitted to your COBOL system. The COBOL source file referenced as the
source of the temporary edit (the "subject program") remains
unchanged, and there is no record of the result of the edit other than the
files output by your COBOL system (listing, and so on). The resulting code file
cannot be animated since there is no source file for reference.
The BASIS mechanism is valid for fixed-format source only.
The program submitted to your COBOL system consists of two files: an
edit control file (containing the BASIS statement and editing information) and
the COBOL source file (the subject program as described above).
Three special statements are associated with the BASIS mechanism:
- BASIS
- INSERT
- DELETE.
These special statements are not part of the COBOL language.
Each one must, in its
entirety, be contained on a single line and must be in upper case.
If you use INSERT
or DELETE statements to modify a COBOL source program specified in a BASIS
statement, the sequence field of the COBOL source program must contain
numeric sequence numbers in ascending order.
General Rules
- A DELETE
statement wholly within area B of the source-program line, not followed
by a valid subject-sequence or subject-sequence-range,
is treated as a
COBOL DELETE statement by your COBOL system.
- Within the BASIS mechanism DELETE statement, all subject-sequence and
subject-sequence-range numbers must be in ascending numeric order.
- Within the edit control file, all subject-sequence and
subject-sequence-range numbers must be in ascending numeric order.
Function
The BASIS statement identifies that the program (the edit control file
and the COBOL source file) is to be submitted to your COBOL system under the
BASIS mechanism rules.
General Format
Syntax Rules
- The BASIS statement must be the first line of the edit control file.
- The BASIS reserved word can commence anywhere between columns 1 and
66 of the statement line.
- Sequence numbers can be included anywhere in columns 1 through 6 of
the statement and must be followed by a space.
- Text-name
defines a unique external file-name which conforms to the rules for
user-defined words. Lower case is translated into upper case.
External-file-name-literal is an alphanumeric literal enclosed in quotation
marks, which conforms to the operating system rules for file-names.
General Rules
- Text-name or external-file-name-literal determines the COBOL source
file to be edited by the control file.
- The editing of the COBOL source file is determined by the INSERT and
DELETE statements in the edit control file.
Function
The DELETE statement (under the BASIS mechanism) identifies lines of the
COBOL source file to be ignored by your COBOL system. Any COBOL statements that
follow the DELETE statement (up to the next BASIS mechanism INSERT or DELETE
statement in the edit control file) are included.
General Format
Syntax Rules
- The DELETE reserved word can commence anywhere between columns 1 and
66 of the statement line.
- Sequence numbers can be included anywhere in columns 1 through 6 of
the statement and must be followed by a space.
- Subject-sequence-1, subject-sequence-2, and so on, must be
6-digit positive
integers (following the rules for integer numeric-literals).
- Subject-sequence-range-1, subject-sequence-range-2, and so on, must
consist of two subject-sequence numbers (as above) separated by a hyphen (-).
- The comma between subject-sequences and/or subject-sequence ranges is
mandatory.
General Rules
- Subject-sequence-1, subject-sequence-2, and so on, refer to sequence
numbers of those statements within the COBOL source file which are to be
ignored by your COBOL system.
- Subject-sequence-range-1, subject-sequence-range-2, and so on, refer
to inclusive ranges of statement sequence numbers within the COBOL source file,
all of which statements are to be ignored when the intermediate code is
produced.
- Any COBOL statements following the DELETE statement in the edit
control file up to the next BASIS mechanism DELETE or INSERT statement
are included in the
source submitted to your COBOL system. These COBOL source statements are
inserted in place of the last statement omitted by this BASIS mechanism DELETE
statement.
Function
The INSERT statement (under the BASIS mechanism) lists lines of COBOL
source to be included in the program submitted to your COBOL system.
General Format
Syntax Rules
- The INSERT reserved word can commence anywhere between columns 1 and
66 of the statement line.
- Subject-sequence must be a
positive numeric
integer (following the rules for integer numeric literals).
General Rules
- Subject-sequence refers to that statement within the COBOL source
file after which the COBOL statement(s) is to be included.
- All the COBOL statements following the INSERT statement in the edit
control file up to the next BASIS mechanism DELETE or INSERT statement
are included in the
source submitted to your COBOL system. At least one COBOL statement must
immediately follow the BASIS mechanism INSERT statement.
The ++INCLUDE and -INC mechanisms provide
an IBM-mainframe
compatible means whereby a COBOL program source file or portion of
source code can be included in a file to be compiled.
Function
The -INC statement is used to include all of the data records of one
source file in another source file at compilation time.
General Format
Directives
- In addition to Compiler directives which provide flagging and modify
the reserved word list, the following directive may impact either the syntax or
the semantics described in this section.
- LIBRARIAN - enables the use of -INC syntax.
Syntax Rules
- -INC must begin in column 1 and be followed by one or more spaces.
- Text-name defines a unique external file-name which conforms to the
rules for user-defined words.
- This special
statement is not part of the COBOL language. It must, in its entirety,
be contained on a single line and must be in upper case.
General Rules
- Text-name determines the COBOL source file to be included at this
specific place in the source code.
- Any other text appearing on the line is treated as a comment.
Function
The ++INCLUDE statement is used to include all of the data records of
one source file in another source file at compilation time.
General Format
Directives
- In addition to Compiler directives which provide flagging and modify
the reserved word list, the following directive may impact either the syntax or
the semantics described in this section.
- PANVALET - enables the use of ++INCLUDE syntax.
Syntax Rules
- ++INCLUDE must begin in column 8, must be in upper case and must be
followed by one or more spaces.
- Text-name defines a unique external file-name which conforms to the
rules for user-defined words.
- This special
statement is not part of the COBOL language. It must, in its entirety,
be contained on a single line and must be in upper case.
General Rules
- Text-name determines the COBOL source file to be included at this
place in the source code.
- Any other text appearing on the line is treated as a comment.
The COBOL system provides a mechanism for selectively compiling part or
all of the COBOL source. To benefit fully from the advantages of conditional
compilation the use of level
78 (see the section
Level Number in the
chapter Data Division - File and Data Description) and the
CONSTANT Compiler directive is recommended. Conditional compilation is
controlled by $IF, $ELSE,
$END constructs, which behave in a similar way to the COBOL IF
construct. Conditional
compilation also supplies the $DISPLAY statement, which can be used to display
a message during compilation or include a version number in the object
file.
Syntax Rules
- Conditional compilation statements are indicated by a dollar ($) in
column 7 in fixed-format source, or column 1 in free-format source of the COBOL
source line followed by one of the key words IF, DISPLAY, ELSE, END.
- Conditional compilation should not be used to split a COBOL character
string; that is, continuation lines should not be split by conditional
compilation controls.
Function
The $DISPLAY statement displays a message on the standard output device
during compilation or includes a version number in the object file.
General Format
Format 1
Format 2
Syntax Rules
- The whole $DISPLAY statement must appear on a single line.
General Rules
- If a $DISPLAY statement is encountered on a source line that is
ignored by conditional compilation, there is neither a compile-time nor a
runtime effect.
Format 1
- Text-data is displayed on the standard output device during
compilation.
Format 2
- Version-number is the content of the entire source line following the
"=", excluding leading and trailing spaces.
- The character string formed by concatenating "@(#)",
version-number and a null character (binary zero) is included in the object
file, no matter which type of object file is created. If version-number begins
with the characters "@(#)", the system does not concatenate these
characters when forming the character string..
Notes:
Function
The $ELSE statement is used in conjunction with the $IF statement to
control conditional compilation.
General Format
Syntax Rules
- The whole statement must appear on a single line.
General Rules
- The most recent $IF condition is reversed. If the now active $IF
condition is true, the source lines following the $ELSE statement are
processed. If the $IF condition is false, COBOL source lines are ignored until
the next conditional compilation line is encountered. .
Function
The $END statement is used in conjunction with the $IF statement to
control conditional compilation.
General Format
Syntax Rules
- The whole statement must appear on a single line.
General Rules
- The innermost $IF statement is terminated. The now active $IF
condition is considered. If the active condition is true the source lines
following the $END are processed. If the condition is false, COBOL source lines
are ignored until the next conditional compilation line is encountered.
Function
A $IF statement provides the means whereby selected parts of the source
text are not included in the compilation.
Examples
- An example of using conditional compilation is provided in
the section
$IF Statement (Conditional
Compilation) in the chapter Examples in your
Language Reference - Additional Topics.
General Formats
Format 1
Format 2
Format 3
Syntax Rules
- Constant-name-1 is defined by a level 78 entry or a CONSTANT Compiler
directive.
- If literal-1 is numeric, it must be zero or a positive integer.
- Directive-setting is specified in the same format as it is given in a
$SET statement and may be preceded by NO.
However, the format used
in the $IF statement differs from the format used in the $SET statement as
follows:
- No spaces are permitted between the NO and directive name
- Hyphens in the directive must be specified exactly
- If the directive has a parameter it may be omitted
- Only directives used in the syntax-check phase and produced in the
directive settings list (see compiler directive SETTINGS) may be specified for
directive-setting
- The whole statement must appear on a single line.
- $IF can be nested within another $IF.
General Rules
- Constant-name-2 is DEFINED if it is the subject of a level 78 entry
or a CONSTANT Compiler directive, otherwise it is NOT DEFINED.
- Directive-setting SET evaluates true if the given setting matches the
actual directive setting. If a parameter is specified then it must also match.
- The comparison between Directive-setting and the actual directive
setting is not case sensitive.
- If the condition evaluates true the source lines following the $IF
statement are processed. If the condition evaluates false, COBOL source lines
are ignored until the next conditional compilation line is encountered.
The listing control statements provide a control for producing output
file listings during the compile process.
Three statements are associated with the listing control statements:
- EJECT
- SKIP1, SKIP2 AND SKIP3
-
TITLE.
Function
The EJECT statement tells your COBOL system to print the next line of
source code at the top of the next page.
General Format
Syntax Rules
- EJECT may begin either in area A or in area B, must be the only
statement on the line and may optionally be followed by a period.
General Rules
- The EJECT statement itself is not printed.
Function
The SKIP1, SKIP2 and SKIP3 statements control the vertical spacing of
the source code listing produced by your COBOL system. They specify the lines
to be skipped in the source code listing.
General Format
Syntax Rules
- The
statement can begin in area A or in area B, must be the only statement
on the line
and can optionally be followed by a period.
General Rules
- SKIP1 tells your COBOL system to skip one line (double spacing).
SKIP2 tells your COBOL system to skip two lines (triple spacing). SKIP3 tells
your COBOL system to skip three lines (quadruple spacing).
- The SKIP statement itself is not printed.
Function
The TITLE statement tells your COBOL system what title to print on the
first line of all subsequent pages of the listing.
General Format
Syntax Rules
- Literal-1 must be nonnumeric and can be followed by a period. It
cannot be a figurative constant.
- The word TITLE can begin either in Area A or Area B and must be the
only statement on the line.
- The TITLE statement can appear anywhere in the compilation group.
General Rules
- Literal-1 is
used as a title on all subsequent pages of the listing. The default
title, which is used until a TITLE directive is encountered, identifies your
COBOL system and its current release level.
- The chosen or default title occupies the left-hand side of the first
line of each page. The remainder of the line gives the date and time the
intermediate code is produced and a page number.
- A second title line is also output containing the name of the main
source file and of the current
text-name
(copybook).
- The TITLE statement causes an immediate new page.
- The TITLE statement itself is not printed.
Your COBOL system, for example, Net Express, provides a large number
of Compiler directives. For details of these, see your COBOL system
documentation.
Copyright © 2002 Micro Focus International Limited. All rights reserved.
This document and the proprietary marks and names
used herein are protected by international law.