[an error occurred while processing this directive]

HP OpenVMS Systems Documentation

Content starts here

HP COBOL
Reference Manual


Previous Contents Index

1.2.1.2 System-Names

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:

ALPHA
ASCII
CARD-READER
CONSOLE
CONTIGUOUS
CONTIGUOUS-BEST-TRY
C01
DEFERRED-WRITE
EBCDIC
EXTENSION
FILL-SIZE
I64
LINE-PRINTER
LOCK-HOLDING
MASS-INSERT
OPERATOR
PAPER-TAPE-PUNCH
PAPER-TAPE-READER
PREALLOCATION
PRINT-CONTROL
SWITCH
VAX
WINDOW

1.2.1.3 Reserved Words

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:

  • Required words
  • Optional words
  • Special-purpose words

Required Word

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.


Optional Words

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.

Special-Purpose Words

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 HP COBOL special registers are primarily used to store information related to or produced by specific HP COBOL features. Table 1-3 shows the special registers, their usage, and their descriptions.

Table 1-3 Special Registers
Special Register Usage---Description
RETURN-CODE (Alpha, I64) X/OPEN---Names an HP 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 and OpenVMS I64, it is initialized to one. On Tru64 UNIX 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.

On Tru64 UNIX the main program sets the shell variable status to the value of the RETURN-CODE. On OpenVMS Alpha and OpenVMS I64 the main program sets the symbol $STATUS to the value of the RETURN-CODE.

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. <STOPPED>

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-STS 1
(OpenVMS)
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 operations. 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-STV 1
(OpenVMS)
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 external.

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-FILENAME 1
(OpenVMS)
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-CURRENT-STS 1
(OpenVMS)
RMS---Names an HP 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-CURRENT-STV 1
(OpenVMS)
RMS---Names an HP 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-CURRENT-FILENAME 1
(OpenVMS)
RMS---Names an HP 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.


1Procedure Division statements can access the values or strings stored in the RMS special registers; however, only the RMS facility can change the contents of the registers. Refer to the HP COBOL User Manual for programming examples. For an explanation and a listing of RMS STS and STV values, refer to the OpenVMS System Messages and Recovery Procedures Reference Manual, an archived manual available on the OpenVMS Documentation CD-ROM, or the online OpenVMS Help Message utility. Refer to the OpenVMS Record Management Services Reference Manual for information on RMS. (RMS is on OpenVMS systems only.)
2The FILE STATUS data item (see Section 6.6.8, I-O Status) provides the primary source of status information for the file I-O verbs, and RMS-STS and RMS-STV provide supplementary information.


Previous Next Contents Index