Portability [ HP COBOL II/XL Programmer's Guide ] MPE/iX 5.0 Documentation
HP COBOL II/XL Programmer's Guide
Portability
Portability applies to both programs and files. The more portable your
program or file is, the less you need to modify it to use it on machines
other than the one for which you originally created it.
This chapter assumes that you are creating your program or file for one
HP 3000 machine and then transporting it to another HP 3000 machine or a
non-HP machine.
To make your program more portable in both cases, do the following:
* Make your program correct.
An incorrect program that works on one machine may not work (or
work the same) on another machine. It may not even work on the
same machine if you recompile it with a later version of the COBOL
compiler.
To this end, do not use the following in your program:
* Uninitalized variables.
* Illegal PERFORM statements (such as recursive PERFORM
statements or two or more PERFORM statements with a common
exit point).
* Branches out of the range of PERFORM statements.
* Do not depend on specific error recovery behavior that the HP
COBOL II/XL Reference Manual does not specify. For example:
* Do not depend on the truncation of digits when there is no
ON SIZE ERROR[REV BEG] phrase.[REV END]
* Do not depend on a specific result when the value of a data
item does not match its PICTURE string (for example,
unsigned data in a signed field).
The rest of this section covers these portability issues:
* Portability between HP 3000 Architectures.
* Portability between HP 3000 and non-HP machines.
* Cross-development.
* HP extensions.
Portability Between HP 3000 Architectures
If you are writing your program for one HP 3000 machine but also intend
to run it on another HP 3000 machine, you should do the following:
* Use the CALL INTRINSIC form of the verb to call an intrinsic.
This tells the compiler an intrinsic is being called and allows it
to adapt the call to a specific operating system.
* Do not use the pseudo-intrinsics .LOC. or .LEN. which call
operating system intrinsics. These are HP Extensions and are
highly machine dependent.[REV BEG] You can use the LENGTH COBOL
function in place of .LEN..[REV END]
* Do not name your program the name of an intrinsic.
* Do not call COBOLLOCK or COBOLUNLOCK which are obsolete COBOL 68
features. Instead, either use the statements EXCLUSIVE and
UN-EXCLUSIVE or call the intrinsics FLOCK and FUNLOCK with CALL
INTRINSIC.
* Do not declare the identifier of a CALL identifier statement to be
numeric.
* Do not assume that external names will be truncated or
dehyphenated. (External names are compiler-generated names that
are recognized outside the program. Chapter 4 explains them.)
* Do not write an illegal program, even if it works on the first
machine for which you are writing the program. It may not work
the same way on another machine. (Examples of illegal things that
may work differently on different machines are: branching out of
PERFORM paragraphs, PERFORM statements with common exit points,
and indirectly recursive PERFORM statements.)
* Do not operate on illegal data, even if the results are
satisfactory on the first machine for which you are writing the
program. The results may cause problems on another machine.
(Examples of illegal data that may cause problems on some machines
but not others are: COMP field overflow, illegal data in
PACKED-DECIMAL or numeric DISPLAY fields, and signed data in
unsigned fields.)
* Do not assume that DISPLAY statement output will have exactly the
same format on different machines.
* Initialize all data items before using them.
* Do not call unsupported or privileged mode intrinsics.
* If you are creating a file for one HP 3000 machine but also intend
to use it on another HP 3000 machine, do not put indexed or SYNC
data items in the file.
Portability Between HP 3000 and Non-HP Machines
If you are writing your program for an HP 3000 machine but also intend to
run it on a non-HP machine, you should do the following:
* Use only ANSI Standard features.
* Do not call system intrinsics directly.
[REV BEG]
To ensure that your program conforms to the 1985 ANSI COBOL Standard, you
can compile your program with the following $CONTROL options: ANSIPARM,
ANSISORT, POST85, and STDWARN.[REV END]
The COBOL standard specifies that the following features are
implementation-defined. Before you use them in your program, check the
specifications of the target machine to ensure that your program will run
correctly on that machine.
* Computer name.
* Function names ASCII, EBCDIC, and EBCDIK in the SPECIAL-NAMES
paragraph.
* Carriage control codes C01 through C16.
* NO SPACE CONTROL.
* TOP.
* Radix of data representation.
* Default representation and position of the sign for numeric data.
* Data alignment.
* External switches SW0 through SW15.
* Area B size.
* Default collating sequences.
* Correspondence between STANDARD-1 and the native character set.
* Default for a record (variable or fixed) when the program contains
no RECORD clause or when the RECORD clause specifies a range of
characters.
* Size and representation of index names and index data items.
* Specific positioning and generation of implicit FILLER in the
SYNCHRONIZED clause.
* Whether data items that do not specify USAGE DISPLAY are
automatically aligned.
* Precise effect of USAGE BINARY, USAGE PACKED-DECIMAL, USAGE
COMPUTATIONAL, and USAGE INDEX on alignment and representation.
* Methods of evaluating arithmetic expressions.
* In the ACCEPT and DISPLAY statements: mnemonic name, size of data
transfer, data conversion (if necessary), and standard device.
* Action after the USE PROCEDURE is executed for an error condition.
* Value of x in 9x file status codes.
* Format and meaning of file-info in the ASSIGN clause.
* Format of file labels.
* Rules for calling non-COBOL subprograms.
If you are creating a file for an HP 3000 machine but also intend to use
it on a non-HP machine, you should do the following:
* Never put indexed data items in the file.
* Do not use SYNC in the file unless the compiler on the non-HP
machine uses 16- or 32-bit synchronization for COMP and BINARY
items. In that case, compile your program with the control option
SYNC16 or SYNC32.
* Specify storage format with USAGE DISPLAY unless the non-HP
machine stores COMP, BINARY, and PACKED-DECIMAL data the same way
that the HP machine on which you are creating the file stores it.
* Realize that although SIGN IS SEPARATE is always portable,
operations on such items are very slow.
* Use ASSIGN clauses.
Cross-Development
Cross-development is the development of a program on an MPE XL system for
the MPE V system, or vice versa. In both cases, you should do the
following:
* Consult the HP COBOL II Migration Guide and avoid features that
are different on the two systems.
* Be sure that the COBCNTL.PUB.SYS files on both systems specify the
same SYNC option, preferably SYNC32.
If you are developing a program on an MPE XL system and intend to run it
on an MPE V system, use the Compatibility Mode compiler. It generates
code that runs on the MPE V system. It also flags features that are not
available on MPE V.
If you are developing a program on an MPE V system and intend to run it
on an[REV BEG] MPE XL system in Native Mode,[REV END] be sure that the
program and its data are portable, because you must recompile the program
on MPE XL.
NOTE Ensure that all variables are properly initialized. Uninitialized
variables that did not cause problems on MPE V systems may cause
programs to abort on MPE XL systems.
HP Extensions
If your program uses HP extensions, you cannot transport it to non-HP
computers. The following are HP extensions to ANSI COBOL 1985:
* NOLIST phrase in the COPY statement.
* USAGE COMP-3 (the standard equivalent is USAGE PACKED-DECIMAL).
* Intrinsic relation condition.
* Random access files.[REV BEG]
* The USING phrase of the ASSIGN clause.[REV END]
* WITH DUPLICATES phrase in the RECORD KEY clause of the SELECT
statement.
* REMARKS paragraph in the IDENTIFICATION DIVISION.
* Abbreviation ID for "IDENTIFICATION".
* Ability to have a section name that is not followed by a paragraph
name.
* Qualified index names.
* Ability to specify the language in the SORT statement.
* ACCEPT FREE form of the ACCEPT statement.
* SEEK statement.
* EXCLUSIVE statement.
* UN-EXCLUSIVE statement.
* CALL statement extensions. These are the INTRINSIC phrase, the
GIVING clause, the symbol "@" or "\" before a parameter.[REV BEG]
* The RETURN-CODE special register.[REV END]
* ENTRY statement (secondary entry points).
* EXAMINE statement.
* GOBACK statement.
* Key name is not required to be on the left-hand side of the SEARCH
ALL condition.
* Index data items in relational conditions.
* Special registers TALLY, CURRENT-DATE, TIME-OF-DAY, and
WHEN-COMPILED.
* Nonnumeric literals longer than 160 characters. (The limit is 255
characters per nonnumeric literal)
* Octal literals.
* Interchangeability of single and double quotes.
* Inequality operator (<>).
* Use of the USE AFTER STANDARD BEGINNING statement to process user
labels for files.[REV BEG]
* Native Language Support using $CONTROL NLS.
* Nested COPY statements.[REV END]
MPE/iX 5.0 Documentation