HPlogo Communicator 3000 MPE/iX Release 6.0 (Platform Software Release C.60.00): HP 3000 MPE/iX Computer Systems > Chapter 10 Technical Articles

COBOL II/iX Enhancements

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Index

by Walter Murray Support Technology Lab

Overview

This release of COBOL II/iX on MPE/iX 6.0 provides several enhancements that were requested by Interex SIGCOBOL. Some of these enhancements have already been made available in various patches to MPE/iX 5.5.

Secondary Entry Points

COBOL II/iX now supports secondary entry points in a main program. To specify a secondary entry point, use the ENTRY statement, and give a nonnumeric literal with the desired entry point name. Specifying that entry point on the MPE/iX RUN command will cause execution to begin at that ENTRY statement. Any number of ENTRY statements may appear, as long as they specify different entry point names. The ENTRY statement is a nonstandard HP extension to the COBOL language.

The following sample program demonstrates the use of a secondary entry point.

      IDENTIFICATION DIVISION.
PROGRAM-ID. UPDATE-MASTER.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 SW-CLEAR-YTD-TOTALS PIC X VALUE "F".
PROCEDURE DIVISION.
0000-BEGIN.
* Enter here for routine processing.
GO TO 1000-MAIN.
ENTRY "YEAREND".
* Enter here for year-end processing.
MOVE "T" TO SW-CLEAR-YTD-TOTALS.
1000-MAIN.
* Update master file, optionally resetting
* year-to-date totals, etc.
DISPLAY "Begin UPDATE-MASTER: SW-CLEAR-YTD-TOTALS = ",
QUOTE, SW-CLEAR-YTD-TOTALS, QUOTE
* ...
STOP RUN.
END PROGRAM UPDATE-MASTER.

Suppose this program is compiled and linked into an executable program named UPDATE. The usual way to invoke it would be with this command:

RUN UPDATE

Alternately, it may be invoked through its alternate entry point, using this command:

RUN UPDATE,YEAREND

CALL by plabel

This enhancement provides an alternate way to achieve execution-time binding with the CALL statement. In standard COBOL, the CALL statement can use an identifier that specifies a nonnumeric data item containing the name of the desired subprogram. COBOL II/iX generates a call to the HPGETPROCPLABEL intrinsic to dynamically load the specified procedure, and that procedure is then executed. The XLs searched in this case are those in the binding sequence of the calling process .

There are situations where it may be desirable for the programmer to call HPGETPROCPLABEL explicitly, for example, when the XL to be searched is not known at load time or is not in the calling program's binding sequence. It is now possible to code your own call to HPGETPROCPLABEL, save the returned procedure label in a numeric data item, and then use that plabel in a CALL statement.

As an example, suppose that the following subprogram has been compiled and placed in an executable library named TESTXL.

      IDENTIFICATION DIVISION.
PROGRAM-ID. COBOLSUB INITIAL.
PROCEDURE DIVISION.
BEGIN.
DISPLAY "In COBOLSUB"
EXIT PROGRAM.
END PROGRAM COBOLSUB.

Using the functionality of call by plabel, this subprogram can now be dynamically loaded and invoked as follows.

      IDENTIFICATION DIVISION.
PROGRAM-ID. COBOL-MAIN.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 PROCNAME PIC X(10) VALUE "-COBOLSUB-".
01 PLABEL PIC S9(9) COMP.
01 FIRSTFILE PIC X(8) VALUE "-TESTXL-".
PROCEDURE DIVISION.
BEGIN.
CALL INTRINSIC "HPGETPROCPLABEL" USING
PROCNAME, PLABEL, \\, FIRSTFILE
CALL PLABEL
STOP RUN.
END PROGRAM COBOL-MAIN.

The ability to use a numeric data item in a CALL statement is a nonstandard HP extension to the COBOL language.

New Routines for Boolean Operations

There are six new routines for performing boolean operations:

  • HP_BYTE_AND

  • HP_BYTE_OR

  • HP_BYTE_XOR

  • HP_BYTE_NOT

  • HP_BYTE_UNPACK

  • HP_BYTE_PACK

These procedures reside in the COBOL II run-time library in XL.PUB.SYS, but may be called from any program running in Native Mode.

The routines HP_BYTE_AND, HP_BYTE_OR, and HP_BYTE_XOR perform bitwise AND, bitwise inclusive OR, and bitwise exclusive OR. The two operands and the result may be any length, but must be the same length, and must be an integral number of bytes. The three routines have identical calling sequences. The first two parameters are the two operands, passed by reference. The third parameter is the result, also passed by reference. The final parameter is the length, in bytes, of the operands, and is passed by value. The first three parameters may not overlap, except in the case where two of them, or all three, are the same data item.

Examples

     CALL "HP_BYTE_AND" USING OPERAND-1, OPERAND-2, RESULT, \4\.
CALL "HP_BYTE_OR" USING DATA-ITEM, MY-BIT-MASK, RESULT, \2\.
CALL "HP_BYTE_XOR" USING INPUT-BUFFER (J:1), RUNNING-XOR,
RUNNING-XOR, \1\.

Note that in COBOL II/iX, backslashes ("\") are used to indicate that a parameter is passed by value. If the parameter is a literal, the backslashes are optional.

The routine HP_BYTE_NOT has the same calling sequence, except that there is only one operand rather than two. The result is computed as the bitwise complement of the operand. The operand and the result must be the same length, and must be an integral number of bytes. They may not overlap, except that the same data item may be used for both.

Example

     CALL "HP_BYTE_NOT" USING OPERAND, RESULT, \4\.

The routine HP_BYTE_UNPACK takes three parameters: an operand, a result, and the length of the operand in bytes. The bits of the operand are unpacked into the result, left to right. Each "zero" bit of the operand becomes an ASCII "0" byte in the result; each "one" bit becomes an ASCII "1" byte. The length specified is the byte length of the operand. The byte length of the result must be 8 times the byte length of the operand.

Example

     01  FIELD-A    PIC S9(4)    COMP.
01 RESULT PIC X(16).
...
MOVE 5 TO FIELD-A.
CALL "HP_BYTE_UNPACK" USING FIELD-A, RESULT, \2\.
DISPLAY RESULT.
* Results in "0000000000000101".

The routine HP_BYTE_PACK is similar. The first parameter, the operand, is a sequence of ASCII bytes. Each byte of the operand is converted to a bit in the result, left to right. An ASCII "0" becomes a "zero" bit; anything other than an ASCII "0" becomes a "one" bit. The length specified is the length of the result in bytes. The byte length of the operand must be 8 times the byte length of the result.

Example

     01  BYTE-STRING    PIC X(16).
01 RESULT-N PIC S9(4) COMP.
...
MOVE "0000000000001111" TO BYTE-STRING.
CALL "HP_BYTE_PACK" USING BYTE-STRING, RESULT-N, \2\.
DISPLAY RESULT-N.
* Results in +15.

Compiling Larger Programs

Internal data structures of the compiler have been expanded to permit compiling significantly larger programs. While there is no specific limit on the number of lines permitted in a source program, this version of the compiler should be capable of processing programs well in excess of 200,000 lines.

DISPLAY Index-name

The compiler has been enhanced to permit an index-name to be used as an operand of a DISPLAY statement. This is an ANSI extension, and if this feature is used and $CONTROL STDWARN is specified, the compiler will display warning 517, DISPLAY of index-name is nonconforming nonstandard HP extension.

New Qedit Diagnostic

The compiler is now able to detect when a source file is in Qedit format and the Qedit product has not been properly installed on the system. Qedit is a full-screen text editor from Robelle Consulting Ltd. In the past, Qedit users have sometimes encountered problems when updating to a new release of MPE/iX and forgetting to reinstall Qedit. COBOL II/iX now detects this condition and produces error 472, QEDIT FORMAT ENCOUNTERED FOR FILE.

Feedback to webmaster