HP 3000 Manuals

New Features [ HP COBOL II/XL Migration Guide ] MPE/iX 5.0 Documentation


HP COBOL II/XL Migration Guide

New Features 

This section describes the new COBOL II/XL features.  These features
include several new $CONTROL options, the EXTERNAL clause, new editing
features of DISPLAY and new ways to trap run-time errors.  These features
are explained in the following sections.

EXTERNAL Clause 

EXTERNAL data items, index names and files provide new ways to pass
information between programs.  This is the first standard way to share
files between programs.  Each EXTERNAL item must be declared in each
program that uses it.  The linker will then match the EXTERNAL items by
name to share the same data space.  (Their names must match exactly.)
They are not passed through the USING phrase, but are matched by name.

For additional details regarding EXTERNAL data and files, refer to the HP 
COBOL II Reference Manual and the HP COBOL II/XL Programmer's Guide.

Nested Programs and the GLOBAL Clause 

You can compile nested COBOL programs and you can compile a source file
consisting of several concatenated source programs.  Both of these
features require the use of the END PROGRAM statement.

When a program contains a nested program and you want the nested program
to have access to the program's data areas, use a GLOBAL clause in the
program.

For information on nesting and the GLOBAL clause, see the HP COBOL II 
Reference Manual and the HP COBOL II/XL Programmer's Guide.

Formatted Output of DISPLAY Statement 

The format of output when displaying unedited signed numeric data items
using the DISPLAY statement has been improved.  For signed items, the
signed overpunch is removed in COBOL II/XL; a leading minus sign is
printed if the number is negative and a leading plus sign is printed if
the number is positive.  A decimal point is inserted where applicable.
Items described with the PICTURE symbol P have zeros inserted.

New $CONTROL Options 

Several new options were added to the $CONTROL command to allow COBOL
programmers to take advantage of the HP precision architecture and the
optimizing compiler, as well as to override defaults in error handling.
Some of these new options also simplify the migration process.

INDEX16 and INDEX32.  You can specify INDEX16 and INDEX32 as options to
the $CONTROL command in COBOL II/XL. These options are used to allocate
storage for INDEX data items.  (Index data items are those data items
which have USAGE IS INDEX in their data description.)  The default on MPE
XL systems is INDEX32; that is, 32 bits (4 bytes) of storage are
allocated for each INDEX data item.

INDEX16 allocates 2 bytes (16 bits) of storage for each INDEX data item.
However, an INDEX data item that has 16 bits of storage allocated to it
cannot be used in COBOL II/XL unless it was created on an MPE XL system.
Therefore, you should only specify this option when reading a record that
contains an INDEX data item embedded in it and if the record was created
on an MPE V system.  INDEX16 allows the byte offsets of the other fields
in the record to remain the same as those on the machine on which it was
created.  Refer to "Example 3:  Index Data Items" in Chapter 5 for an
example of using these options.

RLFILE and RLINIT.  When you compile a program on an MPE XL system, the
compiler produces a relocatable object file (file code NMOBJ) for the
program.  You can then use the HP Link Editor/XL to place the relocatable
object file in a relocatable library (file code NMRL).

Alternatively, you can direct the compiler to place the relocatable
program in a relocatable library directly.  The RLFILE option of the
$CONTROL command lets you do this.  The RLFILE option lets you closely
simulate the placing of object modules in a USL file on MPE V systems.
When you use RLFILE, the compiler assumes that the formal file designator
of the relocatable library is COBOBJ and that it has a file code of NMRL.
The compiler also treats each program in the source file as a separate
compilation unit and places each of the compilation units into the
library as separate relocatable modules.  When you use the RLFILE option,
you can erase modules in an existing library before placing new modules
into it by using the RLINIT option.

If you use the RLFILE option, be sure that the output file (if it already
exists) is a relocatable library with file code NMRL. Additionally, if a
previous compilation created COBOBJ as a relocatable object file, you
must purge the COBOBJ before compiling.

For details about RLFILE and RLINIT, see the HP COBOL II/XL Programmer's 
Guide.

VALIDATE and NOVALIDATE.  On MPE XL systems, validity checking of ASCII
and decimal data is done in the software.  The COBOL II language provides
some validity checking that may be sufficient for your programs.  In
addition, the $CONTROL options, VALIDATE and NOVALIDATE, allow you to
specify whether you want the data to be checked for validity.  The
default is NOVALIDATE; that is, no validation other than that which takes
place within your programs is performed unless you explicitly include the
VALIDATE option.

When a program that was compiled with the VALIDATE option encounters an
illegal ASCII or decimal digit, the message ILLEGAL ASCII DIGIT or
ILLEGAL DECIMAL DIGIT is printed and the program aborts.  To prevent
these errors, you should use a de-edited move to check that no illegal
characters or blanks are placed in a numeric field when moving from an
edited field.  Also, the NUMERIC class condition can be used to detect
invalid digits.  Refer to "Error Handling Options" in this chapter for
how to handle these errors in your programs.  Refer to the HP COBOL II/XL 
Reference Manual for specific information on de-edited moves.

CALLINTRINSIC.  The $CONTROL option, CALLINTRINSIC, assists in migrating
intrinsic calls from COBOL II/V to COBOL II/XL. Using this option causes
the compiler to check the intrinsic file at every CALL statement.  The
compiler issues a warning message for situations when it locates the name
in the intrinsic file and the keyword INTRINSIC was not specified in the
CALL statement.  You should use the CALL INTRINSIC format of the CALL
statement where appropriate.  (Do not use INTRINSIC with IMAGE, VPLUS or
KSAM intrinsics.)

CMCALL.  COBOL II/XL uses different conventions for converting external
names.  The differences, described in the section "Changed Features" in
this chapter, relate to treatment of hyphens, name truncation and case
conversion.  The $CONTROL CMCALL option is used to override the default
external naming convention.  CMCALL does not affect external names
generated by a CALL identifier, a CANCEL identifier or those beginning
with a backslash.  Do not use CMCALL with nested programs.

When you specify this option, an external name is modified as follows:

 *  All hyphens are stripped from the name.

 *  All characters are converted to lowercase.

 *  ames longer than 15 characters are truncated.

A COBOL II program that specifies this option can only call or be called
by the following programs:

   1.  COBOL II programs compiled with this option.

   2.  Compatibility mode programs (through the Switch subsystem).

   3.  Programs written in other languages which assume that external
       names are modified according to the rules previously listed.

OPTFEATURES.  The OPTFEATURES options for the $CONTROL command generate
more efficient code which allow your programs to run faster.  The four
options currently available are:

                             { CALLALIGNED   }
     $CONTROL OPTFEATURES =  { CALLALIGNED16 }
                             { LINKALIGNED   }
                             { LINKALIGNED16 }

CALLALIGNED         $CONTROL OPTFEATURES = CALLALIGNED indicates that all
                    identifiers in the USING phrase of a CALL statement
                    must be aligned on 32-bit boundaries.  An error
                    message is issued for the parameters not on a 32-bit
                    boundary.

LINKALIGNED         Specify $CONTROL OPTFEATURES = LINKALIGNED for
                    subprograms when parameters that will be passed to
                    them are on 32-bit boundaries.  The most efficient
                    code is generated when using the LINKALIGNED option.

When CALLALIGNED/LINKALIGNED ^ais^n used, the compiler checks for proper
32-bit alignment and issues an error message if alignment is incorrect.
When this occurs you must adjust declarations to achieve correct
alignment.  The generated run-time code is most efficient when
CALLALIGNED/LINKALIGNED is used.

When CALLALIGNED/LINKALIGNED is not used the compiler uses the existing
alignment of data and no checking is done.  All parameters are assumed to
be on byte boundaries.  The generated run-time code is least efficient
when CALLALIGNED/LINKALIGNED is not used.

CALLALIGNED16       The CALLALIGNED16 option performs the same checking
                    as CALLALIGNED, except that it looks for a 16-bit
                    alignment.  If the CALLALIGNED16 option is not
                    specified, the compiler will not check the alignment
                    of parameters and will use the existing alignment of
                    data.

LINKALIGNED16       The LINKALIGNED16 option checks that parameters
                    passed to subprograms are on 16-bit boundaries.  The
                    compiler generates more efficient code for accessing
                    formal parameters when the LINKALIGNED16 option is
                    specified; the most efficient code is generated by
                    using the LINKALIGNED option.

When CALLALIGNED16/LINKALIGNED16 is used, the compiler checks for proper
16-bit alignment and issues an error message if alignment is
incorrect.  Declarations must be adjusted to achieve correct
alignment.  The generated run-time code is better when using the
CALLALIGNED16/LINKALIGNED16 options.  If you do not specify the
CALLALIGNED16/LINKALIGNED16 options, the compiler assumes that all
parameters are on byte boundaries and this may cause alignment errors to
occur for calls that pass parameters to COBOL subprograms.

When calling COBOL subprograms, you will not encounter problems if you do
not specify any of the alignment options.  Parameters are only expected
to be aligned if you specify these options.  If CALLALIGNED (or
CALLALIGNED16) is specified in the calling program, however, the COBOL
II/XL compiler issues an error message for any parameter that is not on a
32-bit (or 16-bit) boundary.  You can resolve this problem in several
ways.  First, you can make the data item mentioned in the error message
an 01 or 77 level data item.  If the item is a COMP item, you can add
SYNC to its data description.  Adding fillers in the record declaration
will also align the parameter on a 32-bit boundary.  Finally, you can
remove the alignment options to solve the problem.  (Note that the final
alternative results in less efficient code.)

Alignment considerations between COBOL and non-COBOL program units may
require other options that are specific to the non-COBOL language.  In
that case the documentation for the non-COBOL language should be
referenced.

OPTIMIZE.  The OPTIMIZE option of the $CONTROL command lets you optimize
the code generated in the relocatable object program.  You should use
this option when compiling fully tested production programs.  See the HP 
COBOL II/XL Supplement for details on OPTIMIZE.

Error Handling Options 

COBOL II/XL object programs allow the software to trap a variety of
run-time error conditions.  You can control the response to these
conditions in your program.

The COBOL II/XL compiler supports the following traps:

 *  Illegal Decimal Digit (Error 710).  This error occurs if the program
    is compiled with the $CONTROL VALIDATE option and an illegal decimal
    digit is encountered.  It also occurs when an unsigned number is
    detected in a signed numeric field or vice versa.

 *  Illegal ASCII Digit (Error 711).  This error occurs if the program is
    compiled with the $CONTROL VALIDATE option and an illegal ASCII digit
    is encountered.

 *  Range Error (Error 751).  This error occurs if the program is
    compiled with the $CONTROL BOUNDS option and one of the following
    occurs:  an OCCURS DEPENDING ON identifier is out of bounds; a
    subscript or index is out of bounds; or a reference modification is
    out of bounds.

 *  No SIZE ERROR Clause (Error 747).  This error occurs if a division by
    zero or other size error occurs without an ON SIZE ERROR clause.

 *  Invalid GO TO (Error 754).  This error occurs for an alterable GO TO
    when a particular branch cannot be executed due to program structure
    and/or logic.

 *  Address Alignment (Error 753).  This error occurs if the subprogram
    is compiled with both the $CONTROL BOUNDS and the LINKALIGNED or
    LINKALIGNED16 options and a parameter is passed that is not on a
    32-bit or 16-bit boundary.

 *  Paragraph Stack Overflow (Error 748).  This error occurs when a
    program is compiled with the $CONTROL BOUNDS option and one of the
    following occurs:  a recursive PERFORM, too many nested PERFORM
    statements have the same common exit point or too many illegal GO TO
    statements are used to jump out of paragraphs invoked by a PERFORM
    statement.

The default action when one of these errors occurs is to print an error
message and abort the program.  To specify an action other than the
default, you need to specify a global variable, called COBRUNTIME, equal
to a set of characters.  (A global variable is similar to a job control
word.)  Each character position in COBRUNTIME corresponds to a particular
error condition.  The letter in each character position of COBRUNTIME
instructs the compiler how to handle that particular error, as shown in
Table 2-1.

          Table 2-1.  Run-time Error Handling Options 

--------------------------------------------------------------------------------------------
|                           |                                                              |
|          Option           |                           Meaning                            |
|                           |                                                              |
--------------------------------------------------------------------------------------------
|                           |                                                              |
| A or blank                | Print the error message and abort (default).                 |
|                           |                                                              |
| C                         | Print the error message and continue.                        |
|                           |                                                              |
| D                         | Print the error message and enter debug mode.                |
|                           |                                                              |
| I                         | Ignore (continue without printing an error message).         |
|                           |                                                              |
|                           | This option cancels the $CONTROL options VALIDATE and        |
|                           | BOUNDS, if you use them.  Thus, if both I and VALIDATE are   |
|                           | used, no validity checking takes place.                      |
|                           |                                                              |
|                           | Even though you use I with traps 4-6 in Table 2-2, the       |
|                           | program may still abort.                                     |
|                           |                                                              |
| M                         | Print the error message, fix the illegal digit and continue. |
|                           | This option is only valid for illegal decimal/ASCII digit    |
|                           | errors (see character position 1 in Table 2-2).  When used   |
|                           | for other errors, M is treated as a blank.                   |
|                           |                                                              |
| N                         | Fix illegal digit and continue without printing an error     |
|                           | message.  This option is only valid for illegal              |
|                           | decimal/ASCII digit errors (see character position 1 in      |
|                           | Table 2-2).  When used for other errors, N is treated as a   |
|                           | blank.                                                       |
|                           |                                                              |
--------------------------------------------------------------------------------------------

You set the run-time environment using the MPE XL SETVAR command with the
variable COBRUNTIME:

     SETVAR COBRUNTIME "string"

where "string" is a string of eight uppercase and/or lowercase characters
representing run-time options (A, C, D, I, M, N or blank).  A blank in
the string is interpreted as "Abort," the default.  Each character
position in the string represents a specific trap that you can request,
as shown in Table 2-2.


NOTE The use of the M or N option fixes the illegal digit in the SOURCE data item. This differs from MPE V where the COBOL Library modified the illegal digit within a TEMP cell. The use of the I option is recommended when the modification of the SOURCE field is not desired (for example, subsequent operations such as comparisons depend on the illegal value contained in the SOURCE field).
Table 2-2. Character Position in Specific Traps -------------------------------------------------------------------------------------------- | | | | Character Position | Trap Type | | | | -------------------------------------------------------------------------------------------- | | | | 1 | Illegal ASCII/Decimal Digit. | | | | | 2 | Range Error (OCCURS DEPENDING ON Identifier, Subscript/Index | | | or Reference Modification out of bounds). | | | | | 3 | No SIZE ERROR clause. | | | | | 4 | Invalid GO TO. | | | | | 5 | Address Alignment. | | | | | 6 | Paragraph Stack Overflow (recursive PERFORMs or too many | | | PERFORMs with a common exit point). | | | | | 7 | Leading blanks in a numeric field. If this position | | | contains a value other than N or I, the action entered in | | | character position 1 is taken. | | | | | 8 | An unsigned number in a signed numeric field or a signed | | | number in an unsigned numeric field. If this position | | | contains a value other than N or I, the action entered in | | | character position 1 is taken. | | | | -------------------------------------------------------------------------------------------- For example, for a program that is compiled with the $CONTROL VALIDATE and $CONTROL BOUNDS options: SETVAR COBRUNTIME "M IDCA" has the following effects: * Fixes any illegal ASCII/decimal digits that are found, prints an error message, and continues running. * Aborts if trap on OCCURS DEPENDING ON, Subscript/Index or Reference Modification out of bounds occurs. (These errors may relate to subprograms in other languages.) * Ignores any traps that occur on size errors, division by zero, or Overflow in Exponentiate, if used without an ON SIZE ERROR clause. * Prints an error message and places you in debug mode if an invalid GO TO error occurs. * Prints an error message and continues running on an Address Alignment trap. * Aborts on illegal PERFORMs or illegal GO TOs out of PERFORMed paragraphs.


MPE/iX 5.0 Documentation