HP COBOL II/XL Quick Reference Guide HP 3000 MPE/iX Computer Systems Edition 3 Manufacturing Part Number: 31500-90003 E0791 U.S.A.
Notice The information contained in this document is subject to change without notice. Hewlett-Packard makes no warranty of any kind with regard to this material, including, but not limited to, the implied warranties of merchantability or fitness for a particular purpose. Hewlett-Packard shall not be liable for errors contained herein or for direct, indirect, special, incidental or consequential damages in connection with the furnishing or use of this material.
Printing History New editions are complete revisions of the manual. The dates on the title page change only when a new edition is published. The software code printed alongside the data indicates the version level of the software product at the time the manual or update was issued. Many product updates and fixes do not require manual changes and, conversely, manual corrections may be done without accompanying product changes.
What's New in This Release The following lists major changes to this manual since the last edition: * Addition of Appendix E, which describes the built-in COBOL functions recently defined by Addendum 1 of the ANSI COBOL'85 standard. * Reorganization of the IDENTIFICATION, ENVIRONMENT, DATA, and PROCEDURE DIVISION statements (Chapters 3 through 6). * Miscellaneous changes identified with change bars in the side margins.
extends to the reproduction and use of COBOL specifications in programming manuals or similar publications. FLOW-MATIC (trademark of Sperry Rand Corporation), Programming for the Univac(R) I and II, Data Automation Systems copyrighted 1958, 1959, by Sperry Rand Corporation; IBM Commercial Translator Form No. F 28-8013, copyrighted 1959 by IBM, FACT, DSI 27A5260-2760, copyrighted 1960 by Minneapolis-Honeywell.
{OFF} Within syntax statements, bars in braces are choice indicators. One or more of the items within the choice indicators must be specified, but a single option may be specified only once. {| |} [ ] Within syntax statements, brackets enclose optional elements. In the following example, brackets around ,TEMP indicate that the parameter and its delimiter are not required: PURGE filename [,TEMP] When several elements within brackets are stacked, you can select any one of the elements or none.
TO, LESS THAN OR EQUAL TO, GREATER THAN OR EQUAL TO, and NOT EQUAL TO, respectively. Although these symbols represent keywords, they are not underlined. ; The semicolon is used only to improve readability and is always optional. , The comma is used only to improve readability, and is always optional. . The period is a terminator or delimiter that is always required where shown; it must always be entered at the end of every division name, section name, paragraph name, and sentence.
Chapter 1 Preprocessor Commands and $CONTROL Options Table 1-1. Preprocessor Commands --------------------------------------------------------------------------------------------| | | | Command | Purpose | | | | --------------------------------------------------------------------------------------------| | | | $COMMENT | Writing comment lines. | | | | --------------------------------------------------------------------------------------------| | | | $DEFINE | Defining and using macros.
Syntax $COMMENT [ comment-text ] Parameters comment-text a string containing anything you want to enter. comment-text requires no delimiters. It ends at the end of the line where the $COMMENT command is issued unless a continuation character is used. Use of COBOL comments, "*", is preferred. $CONTROL The $CONTROL command controls compilation and list options.
STAT74 STDWARN[=level ] NOSTDWARN SUBPROGRAM SYMDEBUG SYNC16 SYNC32 USLINIT VALIDATE (1) NOVALIDATE (1) VERBS NOVERBS WARN NOWARN (1) This option is available only on HP COBOL II/XL. The default $CONTROL options are shown below: $CONTROL NOCODE, NOCROSSREF, ERRORS=100, LINES = 60, QUOTE=", LIST, LOCON, & $ NOMAP, MIXED, SOURCE, NOSTDWARN, NOVERBS, WARN For a description of other $CONTROL commands, refer to the HP COBOL II/XL Reference Manual.
sentence, with one exception. This exception is the use of formal parameters in the string-text. $EDIT The $EDIT preprocessor command can be used to bypass all records of the masterfile whose sequence fields contain a certain value, and renumber the numeric sequence fields of records in the newfile created by merging a textfile and a masterfile. Syntax $EDIT [ parameter=subparameter ] [, parameter=subparameter ] [...] Parameters parameter subparameter either VOID, SEQNUM, NOSEQ, or INC.
$PREPROCESSOR The $PREPROCESSOR command allows you to change the default characters used in macro definitions and names. Syntax $PREPROCESSOR parameter=subparameter [, parameter=subparameter ] Parameters parameter one of the keywords shown below. Each may be used only once in a given $PREPROCESSOR command. KEYCHAR specifies that the initial character of all macro names is to be subparameter.
of string must be preceded and followed by a quotation mark (") or an apostrophe ('). The total number of characters used in the strings is limited to 255. This includes any blanks appearing in strings, but does not include the quotation marks used to delimit the strings.
Chapter 2 Program Format 2- 1
2-: 2
Chapter 3 IDENTIFICATION DIVISION The IDENTIFICATION DIVISION has the following format: 3-: 1
3-: 2
Chapter 4 ENVIRONMENT DIVISION 4- 1
CONFIGURATION SECTION SOURCE-COMPUTER Paragraph [SOURCE-COMPUTER. [computer-name 4- 2 [WITH DEBUGGING MODE ].
OBJECT-COMPUTER Paragraph .
Table 4-1. HP COBOL II Feature, Switch, and Device Names -------------------------------------------------------| | | | Feature Name | Function | | | | -------------------------------------------------------| | | | CONDITION-CODE | Refers to condition codes | | | returned by operating system | | | intrinsics when they have been | | | called through the CALL | | | statement.
Table 4-1. HP COBOL II Feature, Switch, and Device Names (cont.) -------------------------------------------------------| | | | Switch Name | Function | | | | -------------------------------------------------------| | | | SW0 | Refer to software switches | | through | associated with condition | | SW15 | names. (Software switches are | | | described in the next section | | | of this chapter.
INPUT-OUTPUT SECTION File Control Clauses 4- 6
4- 7
Table 4-2. ANSI COBOL'85 File Status Codes -------------------------------------------------------------------------------| | | | | | | | RANDOM ACCESS or | | | | SEQUENTIAL | RELATIVE | INDEXED | | | | | | -------------------------------------------------------------------------------| | | | | | S | 00-Successful. No | 00-Successful. No | 00-Successful. No | | U | more information | more information | more information | | C | available. | available. | available.
Table 4-2. ANSI COBOL'85 File Status Codes (cont.) -------------------------------------------------------------------------------| | | | | | | | RANDOM ACCESS or | | | | SEQUENTIAL | RELATIVE | INDEXED | | | | | | -------------------------------------------------------------------------------| | | | | | P | 30-No more | 30-No more | 30-No more | | E | information | information | information | | R | available.[REV BEG] | available.[REV BEG]| available.
Table 4-2. ANSI COBOL'85 File Status Codes (cont.) -------------------------------------------------------------------------------| | | | | | | | RANDOM ACCESS or | | | | SEQUENTIAL | RELATIVE | INDEXED | | | | | | | | | | | | L | 41-OPEN on file | 41-OPEN on file | 41-OPEN on file | | O | that is | that is | that is | | G | already open. | already open. | already open. | | I | 42-CLOSE for file | 42-CLOSE for file | 42-CLOSE for file | | C | not open. | not open. | not open.
Table 4-3. ANSI COBOL'74 File Status Codes -------------------------------------------------------------------------------| | | | | | | | RANDOM ACCESS or | | | | SEQUENTIAL | RELATIVE | INDEXED | | | | | | -------------------------------------------------------------------------------| | | | | | S | 00-Successful. No | 00-Successful. No | 00-Successful. No | | U | more information | more information | more information | | C | available. | available. | available.
I-O-CONTROL Paragraph 4- 12
fi Chapter 5 DATA DIVISION 5-: 1
FILE SECTION . .
fi Table 5-1. Values of the LABEL INFO and DATA NAME Parameters in the VALUE OF Clause ----------------------------------------------------------------------------------------------- label-info-n Meaning data-name-n or literal-n ----------------------------------------------------------------------------------------------| VOL | Volume identification. | Any combination of one to six characters | | | | from the set A through Z, and 0 through 9.
Data Description .
fi The table below summarizes the type of editing permitted for each category. Table 5-2. Allowable Types of Editing For Categories of Data Items ------------------------------------------------------| | | | Category | Type of Editing | | | | ------------------------------------------------------| | | | Alphabetic | Simple insertion B only. | | | | ------------------------------------------------------| | | | Numeric | None.
The table below shows the units digit, with the sign of its associated number represented in ASCII code. Table 5-3.
Chapter 6 PROCEDURE DIVISION The PROCEDURE DIVISION has the following format: .
Imperative Statements and Sentences The following table lists verbs used in forming imperative statements. Table 6-1.
PROCEDURE DIVISION Statements ACCEPT Statement .
ADD Statement ALTER Statement ALTER Statement ALTER 6- 4 {procedure-name-1 TO [PROCEED TO ] procedure-name-2 }...
CALL Statement 6-: 5
CANCEL Statement .
DELETE Statement DISPLAY Statement DIVIDE Statement 6-: 7
ENTER Statement ENTER language-name [routine-name ]. ENTRY Statement ENTRY 6- 8 literal-1 [USING {data-name-1 }...
EVALUATE Statement .
EXCLUSIVE Statement file-name EXCLUSIVE [CONDITIONALLY ] EXIT Statement paragraph-name. EXIT. paragraph/section-name. EXIT PROGRAM Statement EXIT PROGRAM GOBACK Statement GOBACK GO TO Statement GO TO [procedure-name-1 ] GO TO {procedure-name-1 }...
INSPECT Statement 6-: 11
MERGE Statement MOVE Statement 6- 12
Table 6-2.
MULTIPLY Statement .
PERFORM Statement .
6- 16
READ Statement RELEASE Statement RELEASE record-name-1 [FROM identifier-1 ] REPLACE Statement 6-: 17
RETURN Statement REWRITE Statement 6- 18
SEARCH Statement SEEK Statement SEEK file-name RECORD 6-: 19
SET Statement SORT Statement 6- 20
START Statement STOP Statement STRING Statement 6-: 21
SUBTRACT Statement UN-EXCLUSIVE Statement UN-EXCLUSIVE 6- 22 file-name-1
UNSTRING Statement USE Statement 6-: 23
WRITE Statement .
General Format for Conditions Abbreviated Combined Relation Condition Format Class Condition Format Combined Condition Format Condition-Name Condition Format condition-name-1 6-: 25
Intrinsic Relation Condition Format Negated Condition Format NOT condition-name-1 Relation Condition Format 6- 26
Sign Condition Format Switch-Status Condition Format condition-name-1 Miscellaneous Formats Qualification 6-: 27
Subscripting/Indexing .
Special Register Words Table 6-2. Special Register Words --------------------------------------------------------| | | | Word | Contents | | | | --------------------------------------------------------| | | | LINAGE-COUNTER | An unsigned number used to keep | | | track of the number of lines | | | written to each page of a | | | printed report. | | | | --------------------------------------------------------| | | | DEBUG-ITEM | A data item used in support of | | | the COBOL DEBUG facility.
Figurative Constant Words Table 6-3. Figurative Constant Words ------------------------------------------------------------| | | | Word | Constant Value | | | | ------------------------------------------------------------| | | | ALL literal | The character string denoted by the | | | variable literal.
Appendix A HP COBOL II/XL Compiler Commands Command Files These are the MPX XL command files you can use to compile, link, and execute HP COBOL II/XL programs. The syntax follows. Table A-1.
Parameters textfile MPE or TSAM file containing your source program. file can be compiled. The default is $STDIN. objectfile Relocatable object code file. This file can be linked. The default is $NEWPASS or $OLDPASS. The object file code can be NMOBJ or NMRL. The compiler will take the appropriate actions for existing files. progfile Executable program file. The default is $NEWPASS. listfile File on which your source code will be listed. default is $STDLIST.
Appendix B COBOL II/XL Compiler Commands Any of the commands or UDCs that are summarized below can be used to invoke the HP COBOL II/V compiler. The COBOLII commands invoke the ANSI COBOL'74-compatible COBOLII compiler through the ANSI COBOL'74 entry point. The COBOLIIX system-wide UDCs invoke the extended COBOLII compiler through the ANSI COBOL'85 entry point. This provides access to the ANSI COBOL'85 feature set.
B-2
Appendix C MPE/XL Run-Time Trap Handling The HP COBOL II/XL compiler handles run-time traps for cases of bounds checking, divide by zero, invalid GOTO statements, and alignment errors. The run-time environment is set using the MPE XL SETVAR command with the variable COBRUNTIME.
| | | | 3 | No SIZE ERROR phrase. | | | | ------------------------------------------------------------------------------| | | | 4 | Invalid GO TO. | | | | ------------------------------------------------------------------------------| | | | 5 | Address Alignment. | | | | ------------------------------------------------------------------------------| | | | 6 | Paragraph stack overflow (recursive PERFORMs or too many | | | PERFORMs with a common exit point).
Appendix D COBEDIT Program The COBEDIT program develops and maintains COPY libraries. This program resides in the PUB group of the SYS account. It allows you to create, modify, and list a COBOL COPY library file. To enter the COBEDIT program, issue the following command: COBEDIT Table D-1.
COPY The COPY command allows you to copy additional modules into a library that was created previously using the BUILD command. To use COPY, the library must be the current library or it must be activated by using the LIBRARY command. Syntax COPY EDIT The EDIT command calls the EDIT/3000 subsystem, and optionally allows you to name a module from the currently active library to be edited. Syntax [ text-name EDIT ] Parameters text-name the name of a module in the currently active library.
library. ALL indicates that all modules in the library are to be listed, beginning with the first module on the file, and proceeding to the last. PURGE The PURGE command allows you to purge either a single module from your currently active library or the entire library. Syntax PURGE {text-name } {ALL } Parameters text-name is the name of a module to be purged from the currently active library. This is the module to be purged.
D-: 4
Appendix E COBOL Functions The following tables lists and briefly describes each COBOL function. The syntax for each function follows. Table E-1. Date Functions -------------------------------------------------------------------Function Type Value Returned -------------------------------------------------------------------| CURRENT-DATE | Alphanumeric | Current date and time and | | | | difference from Greenwich Mean | | | | Time.
Table E-3. General Functions -------------------------------------------------------------------Function Type Value Returned -------------------------------------------------------------------| MAX | Depends on | Maximum value of all parameters. | | | parameters. | | -------------------------------------------------------------------| MIN | Depends on | Minimum value of all parameters. | | | parameters.
| PRESENT-VALUE | Numeric | Present value of a series of | | | | future period-end amounts at a | | | | given discount rate. | -------------------------------------------------------------------| RANGE | Integer or | Value of largest parameter minus | | | Numeric | value of smallest parameter. | -------------------------------------------------------------------| STANDARD| Numeric | Standard deviation of | | DEVIATION | | parameters.
Parameters parameter-1 Must be class numeric and must be greater than or equal to zero. parameter-2 Must be a positive integer. ASIN The ASIN function returns the arcsine of the parameter. type is numeric. The function Syntax FUNCTION ASIN (parameter-1 ) Parameters parameter-1 Must be class numeric and must be between -1 and 1, inclusive. ATAN The ATAN function returns the arctangent of the parameter. type is numeric.
Syntax FUNCTION DATE-OF-INTEGER (parameter-1 ) Parameters parameter-1 A positive integer that represents a number of days succeeding December 31, 1600 in the Gregorian calendar. DAY-OF-INTEGER The DAY-OF-INTEGER function converts a date in the Gregorian calendar from integer date form to Julian date form (YYYYDDD). The function type is integer.
The INTEGER-OF-DAY function converts a date in the Gregorian calendar from Julian date form (YYYYDDD) to integer date form. The function type is integer. Syntax FUNCTION (parameter-1 ) INTEGER-OF-DAY Parameters parameter-1 Must be an integer of the form YYYYDDD, whose value is obtained as follows: (YYYY * 1000) + DDD where YYYY represents the year in the Gregorian calendar and must be an integer greater than 1600. DDD represents the day of the year and must be a positive integer less than 367.