All user-defined words in a program, except segment-numbers and level-numbers, can belong to only one of these sets. User-defined words in each set must be unique, except as described in the rules for uniqueness of reference. (See Section 6.2).
Except for section-names, paragraph-names, segment numbers, and
level-numbers, all user-defined words must contain at least one
alphabetic character. Segment-numbers and level-numbers need not be
unique. Any segment-number or level-number can be the same as any other
segment-number or level-number.
System-names are COBOL words that refer to the program's operating environment. The same COBOL word can be used in a program as both a user-defined word and a system-name. The compiler determines the word's class from its context.
The system-names are as follows:
A reserved word can be used only as specified in the general formats. It cannot be a user-defined word. (See Appendix A for a list of reserved words.)
The three types of reserved words follow:
A required word must be used when its format is used in a program.
The two types of required words are keywords and special character words. In general formats, keywords are uppercase and underlined. Arithmetic operators and relation characters are special character words; they are not underlined in the general format.
In the following sample format, the keywords are COMPUTE, ROUNDED, SIZE, ERROR, NOT, and END-COMPUTE. The equal sign (=) is a special-character word.
In general formats, uppercase words that are not underlined are optional words. They can make a program more human-readable, but have no semantic effect. In the previous sample format, ON is an optional word.
The two types of special-purpose words are figurative constants and special registers. Figurative constants name and refer to specific constant values and are described in detail in Section 1.2.3. Special registers name and refer to special storage areas that the compiler provides.
The Compaq COBOL special registers are primarily used to store information related to or produced by specific Compaq COBOL features. Table 1-3 shows the special registers, their usage, and their descriptions.
X/OPEN---Names a Compaq COBOL special register that may be used to set
a return value for a calling program or to retrieve the value returned
from a called program. It is represented by PIC S9(9) USAGE IS COMP. It
is implicitly defined with GLOBAL scope.
The RETURN-CODE register is initialized with the platform-specific success code. On OpenVMS Alpha, it is initialized to one. On Tru64 UNIX and Windows NT it is initialized to zero.
The RETURN-CODE special register can be set by a called program, prior to the execution of a STOP RUN or EXIT PROGRAM statement, to pass a value to the calling program or the execution environment. For a calling program, it can be read, subsequent to the CALL, to obtain the value of the RETURN-CODE set by the called program.
If you use the GIVING phrase on the CALL statement or on the Procedure Division header, specifying a data item as its argument, this data item (instead of RETURN-CODE) receives the return value. Note that you can specify the special register RETURN-CODE as the argument to GIVING, in which case RETURN-CODE receives the return value. For more information on the relationship between the GIVING phrase and the RETURN-CODE special register, see Table 6-7 in Chapter 6.
Because the reserved word RETURN-CODE is one of the X/Open reserved words, you cannot use the noxopen keyword in the reserved_words compiler option if you want to use the RETURN-CODE special register.
For related information, see Section 6.8 for the syntax and description of the GIVING phrase of the Procedure Divison header; and the CALL statement for the syntax and description of CALL GIVING.
|LINAGE-COUNTER||LINAGE files---A line counter that the compiler provides when a file description entry contains a LINAGE clause. Its value is the number of the current record within the page body. (See the Section 5.3.31 clause in Chapter 5.) The implicit size of LINAGE-COUNTER is nine decimal digits represented by PIC S9(9) COMP. You can qualify LINAGE-COUNTER with a file-name. Procedure Division statements and the SOURCE clause of the Report Section can access the value of LINAGE-COUNTER but cannot change its value. LINAGE-COUNTER is global if file-name is global and external if file-name is external.|
|PAGE-COUNTER||REPORT WRITER---A page counter that the compiler provides for each report in the Report Section of the Data Division. You can qualify PAGE-COUNTER with a report-name. Its value is the number of the current page within a report. The implicit size of PAGE-COUNTER is six unsigned decimal digits represented by PIC 9(6) COMP. The Report Writer Control System (RWCS) maintains the value of PAGE-COUNTER and uses this value to number the pages of a report. The SOURCE clause of the Report Section can reference PAGE-COUNTER. The values in PAGE-COUNTER range from 1 to 999999 and can be altered by Procedure Division statements.|
|LINE-COUNTER||REPORT WRITER---A line counter that the compiler generates for each report in the Report Section of the Data Division. It may be qualified by a report-name. Its value is the number of the current line within a page. (See PAGE-COUNTER.) The implicit size of LINE-COUNTER is six unsigned decimal digits represented by PIC 9(6) COMP. The Report Writer Control System (RWCS) maintains the value of LINE-COUNTER and uses this value to determine the vertical positioning of a report. The SOURCE clause of the Report Section can reference LINE-COUNTER. The values in LINE-COUNTER range from 0 to 999999. Procedure Division statements can access the values in LINE-COUNTER; however, only the RWCS can change its value.|
RMS---Contains the primary RMS status value of an I/O operation.
(RMS-STV contains the secondary value.) RMS-STS provides additional
information on COBOL File Status values resulting from I/O
2 It is represented by PIC S9(9) USAGE IS COMP. You must
qualify RMS-STS with a file-name. If the file-name is global, RMS-STS
is also global. If the file-name is external, RMS-STS is also external.
Before the program opens the file for the first time, the value of RMS-STS is undefined. After your program executes an OPEN or CLOSE statement, RMS-STS is set to the value of the STS field in the associated file access block (FAB). After executing a READ, WRITE, REWRITE, DELETE, START, or UNLOCK statement, RMS-STS is set to the value of the STS field in the associated record access block (RAB).
RMS---Contains the secondary (RMS-STS is primary) RMS status value of
an I/O operation. The interpretation of this value is dependent on the
value in RMS-STS. It is represented by PIC S9(9) USAGE IS COMP. You
must qualify RMS-STV with a file-name. If the file-name is global,
RMS-STV is also global. If the file-name is external, RMS-STV is also
The value in RMS-STV is undefined prior to the initial OPEN of the file. After your program executes an OPEN or CLOSE statement, RMS-STV is set to the value of the STV field in the associated FAB. After executing a READ, WRITE, REWRITE, DELETE, or START statement, RMS-STV is set to the value of the STV field in the associated RAB.
RMS---Names the complete RMS filename. It consists of 255 alphanumeric
characters represented by PIC X(255) USAGE IS DISPLAY. You must qualify
it with a file-name. If the file-name is global, RMS-FILENAME is also
global. If the file-name is external, RMS-FILENAME is also external.
Before the program opens the file for the first time, the value of RMS-FILENAME is undefined. For each COBOL OPEN statement, RMS-FILENAME is set to the complete RMS file specification string of file-name: for example, DBB1:[COBOL]MASTER.DAT.
RMS---Names a Compaq COBOL exception condition register. It contains
the primary RMS status value of the most recent RMS I/O operation,
regardless of the file operated on. (RMS-CURRENT-STV contains the
secondary value.) It is represented by PIC S9(9) USAGE IS COMP. Since
this register can contain the primary RMS status value for any file,
you must not qualify it with a file-name.
After your program executes any RMS I/O operation, it sets RMS-CURRENT-STS to the value contained in RMS-STS for that file.
|RMS---Names a Compaq COBOL exception condition register. It contains the secondary RMS status value of the most recent RMS I/O operation, regardless of the file operated on. (RMS-CURRENT-STS contains the primary value.) It is represented by PIC S9(9) USAGE IS COMP. Since this register can contain the secondary RMS status value for any file, you must not qualify it with a file-name. After your program executes any RMS I/O operation, it sets RMS-CURRENT-STV to the value contained in RMS-STV for that file.|
RMS---Names a Compaq COBOL exception condition register. It contains
the complete RMS file specification string of the file most recently
operated on by an I/O
statement. It consists of 255 alphanumeric characters represented by
PIC X(255) USAGE IS DISPLAY. Since this register can contain the
file-name for any file, you must not qualify it with a file-name.
After your program executes any I/O operation, it sets RMS-CURRENT-FILENAME to the string contained in RMS-FILENAME for that file.
A function-name is the name of a function as shown in
Table 7-1, Intrinsic Functions. Note that function-names are not reserved words and may
appear in a different context in a program as a user-defined word or a
A literal is a character-string whose value is specified by: (1) the ordered set of characters it contains, or (2) a reserved word that is a figurative constant.
Compaq COBOL provides two types of literals: numeric and nonnumeric.
Numeric literals include floating-point literals and nonnumeric
literals include hexadecimal and national literals. Floating-point,
hexadecimal, and national literals are Compaq extensions. The following
two sections describe literals in detail.
22.214.171.124 Numeric Literals
A numeric literal is a character string of 1 to 33 characters selected from the digits 0 to 9, the plus sign (+), the minus sign (-), and the decimal point (.).
The value of a numeric literal is the algebraic quantity represented by the characters in the literal.
Table 1-4 provides examples of numeric literals.
A floating-point literal, a Compaq extension to numeric literals, is a character-string whose value is specified by 4 to 37 characters selected from the digits 0 to 9, the plus sign (+), the minus sign (-), the decimal point (.), and the letter E (uppercase or lowercase).
You can use floating-point literals to achieve a wider range of numeric literal values.
The value of a floating-point literal is the algebraic quantity
represented by the characters in the literal that precede the E
multiplied by ten raised to the power of the algebraic quantity
represented by the characters in the literal following
Table 1-5 provides a few examples of floating-point literals.
A nonnumeric literal is a character-string of 0 to 256 characters. It is delimited on both ends by quotation marks (") or apostrophes ('). A nonnumeric literal delimited by apostrophes is treated in the same manner as a nonnumeric literal delimited by quotation marks.
The value of a nonnumeric literal is the value of the characters in the character-string. It does not include the quotation marks (or apostrophes) that delimit the character-string. All other punctuation characters in the nonnumeric literal are part of its value.
The compiler truncates nonnumeric literals to a maximum of 256 characters.
Table 1-6 provides examples of nonnumeric literals. In these examples, s represents a space character.
A hexadecimal literal (a Compaq extension to nonnumeric literals) is a character string of 2 to 256 hexadecimal digits. On the left it is delimited by the separator X (or x) immediately followed by a quotation mark (") or apostrophe ('); on the right it is delimited by a matching quotation mark or apostrophe. For example:
03 HEX_VAL PIC X VALUE X"00".
The character string consists only of pairs of hexadecimal digits representing a byte value ranging from 00 to FF; hence, only the characters 0 to 9, A to F, and a to f are valid.
The value of a hexadecimal literal is the composite value of the paired hexadecimal representations. The compiler truncates hexadecimal literals to a maximum of 128 hexadecimal representations (pairs of hexadecimal digits).
A hexadecimal literal can be used interchangeably wherever a nonnumeric literal can appear in Compaq COBOL syntax. (Thus, hexadecimal literals cannot be used as operands in arithmetic statements.)
Table 1-7 provides examples of hexadecimal literals.
National literals can be from 0 to 128 2-byte characters (hence 256 bytes). The syntax is:
National literals are made available when /NATIONALITY=JAPAN or -nationality japan is specified.