Compaq COBOL
User Manual
B.4.10 Calling Shareable Images
On OpenVMS, Compaq COBOL and Compaq COBOL for OpenVMS VAX exhibit different
behavior when calling a subprogram installed as a shareable image. With
Compaq COBOL, the program name you specify in a CALL statement can be
either a literal or a data-name. (The same is true for the CANCEL
statement.) With Compaq COBOL for OpenVMS VAX, the program name you specify in a CALL
(or CANCEL) statement must be a literal. In addition, Compaq COBOL for OpenVMS VAX
programs installed as shareable images cannot contain external files.
(See Chapter 1 and OpenVMS Linker Utility Manual for more information about
shareable images.) <>
On Windows NT and Tru64 UNIX systems, Compaq COBOL exhibits
behavior more like Compaq COBOL for OpenVMS VAX with regard to shared objects.
(Shared objects are the Windows NT and Tru64 UNIX equivalent to
OpenVMS shared images.) For more information, see
Chapter 12, Interprogram Communication. <>
B.4.11 Sharing Common Blocks (OpenVMS)
On OpenVMS, to prevent problems when you link a Compaq COBOL program
and want to share a common block between processes, you should set the
PSECT attribute to SHR (the defaults are: SHR on OpenVMS Alpha
systems, NOSHR on OpenVMS VAX systems). Also, you should add a
SYMBOL_VECTOR to the linker options file of the shareable image, as
follows:
SYMBOL_VECTOR = (psect-name = PSECT)
|
For more information, see the OpenVMS Linker Utility Manual. <>
B.4.12 Arithmetic Operations
Several arithmetic operations differ in behavior between Compaq COBOL
and Compaq COBOL for OpenVMS VAX, depending upon your platform:
- Results of numeric and integer Intrinsic Functions may differ from
Compaq COBOL for OpenVMS VAX or may be formatted differently by a DISPLAY statement.
- OpenVMS VAX and OpenVMS Alpha handle COMP-2 items differently.
As a result, DISPLAY of a USAGE COMP-2 data item low order digits may
be different from the low order digits of the data item from the
DISPLAY with Compaq COBOL for OpenVMS VAX on OpenVMS VAX.
- Compaq COBOL issues the ALL_LOST (all digits lost) warning
diagnostic in different cases than Compaq COBOL for OpenVMS VAX.
- When overflow occurs in an arithmetic statement without a SIZE
ERROR phrase and native arithmetic is used, the results are undefined.
Compaq COBOL for OpenVMS VAX often returns the low order digits of the true result in
such cases; Compaq COBOL does not. When standard arithmetic is used,
the results are unaltered.
- The precision of intermediate results is different between
Compaq COBOL for OpenVMS VAX and Compaq COBOL. This is most noticeable in COMPUTE
operations involving a divide. If you need a specific precision for an
intermediate result, you should use a temporary variable with the
desired precision. For example:
...could be written as
COMPUTE TMP1 = A / B.
COMPUTE D = TMP1 / C.
|
The precision to be used for the calculation A / B would be
established by your declaration of TMP1.
- On Windows NT and Tru64 UNIX, the VAX floating
point data types, F_FLOAT, D_FLOAT, and G_FLOAT are not supported;
whereas, on OpenVMS Alpha systems, F_FLOAT and D_FLOAT are the
defaults for floating point. This difference potentially affects
reading data files with COMP-1 and COMP-2 keys built on OpenVMS Alpha
systems. Also, any programs that check for specific floating values
rather than ranges of values may be impacted.
- The results of numeric comparisons with Compaq COBOL for OpenVMS VAX and
Compaq COBOL are undefined with invalid decimal data. Compaq COBOL
includes the /CHECK=DECIMAL and
-check decimal
features to do a more complete analysis of invalid decimal data. These
options can be particularly helpful when you are migrating programs to
Compaq COBOL.
-
There is some inevitable incompatibility in results of arithmetic
operations involving large intermediate values, between Compaq COBOL
and Compaq COBOL for OpenVMS VAX. In Compaq COBOL, to minimize the differences, you
can use the /MATH_INTERMEDIATE=CIT3 qualifier (or
-math_intermediate cit3
). With it, use the /ARITHMETIC=NATIVE qualifier (or
-arithmetic native
), which is the default. (Specifying /ARITHMETIC=STANDARD would force
/MATH_INTERMEDIATE=CIT4.)
CIT3 gives improved compatibility between
Compaq COBOL and Compaq COBOL for OpenVMS VAX. Even with CIT3, however, there are
differences:
- Invalid decimal data
In Compaq COBOL, invalid decimal data
detection takes place before any possible conversion to CIT3. CIT3
operations on data items containing invalid decimal data will get
results possibly different from those with Compaq COBOL for OpenVMS
VAX.
- Floating-point data items
In Compaq COBOL, expressions
involving COMP-1 or COMP-2 data items are converted to G_floating (on
OpenVMS Alpha) or T_floating before conversion to CIT3. CIT3 operations
involving D_floating (on OpenVMS Alpha) data items, in particular, will
get different results from Compaq COBOL for OpenVMS VAX.
- Undefined results
If an abnormal condition arises during a
CIT3 operation, for example, INTEXPOVE (intermediate exponent
overflow), and the program continues, and it is not an arithmetic
statement with an ON SIZE ERROR clause, then the values that are stored
in destination items will be undefined. Compaq COBOL and
Compaq COBOL for OpenVMS VAX are highly likely to get different
undefined results in such cases.
- STANDARD dependency
The Compaq COBOL for OpenVMS VAX
/STANDARD qualifier has an effect on when arithmetic expression
analysis switches to one of the CIT forms. When you specify
/STANDARD=V3 (-std v3), CIT is used when more than 18 digit
intermediate results are needed. With /STANDARD=85 (-std 85), CIT is
used when more than 31 digit intermediate results are needed. The
Compaq COBOL implementation on Alpha is compatible with
Compaq COBOL for OpenVMS VAX with /STANDARD=85.
- Special contexts
The CIT3 implementation does not provide
support equivalent to the Compaq COBOL for OpenVMS VAX behavior for
intrinsic functions MEDIAN, NUMVAL, and NUMVAL-C.
See
Section 2.7.1 in this manual, and the Compaq COBOL Reference Manual for more
information on the /MATH_INTERMEDIATE and /ARITHMETIC qualifiers.
B.5 Compaq COBOL Differences Across Operating Systems
Certain Compaq COBOL features have unique behaviors, depending upon
which of these operating systems you are using, and sometimes these
differences differ from release to release. You should refer to the
Release Notes to get the most recent information about these
differences. The next few sections describe distinct differences in
feature implementation and behavior.
B.5.1 REWRITE
A REWRITE operation for an ISAM file is dependent on whether the
DUPLICATES clause for the primary key is specified. There is an
ambiguity when DUPLICATES is specified in one way at the time a file is
created, and another way when it is reopened (a program should use the
same declarations). Both Compaq COBOL for OpenVMS VAX and Compaq COBOL for
OpenVMS Alpha use the specification of the current program. So, if
DUPLICATES was specified for the primary key when a file was created,
but not when reopened by the current program, the behavior will be as
if DUPLICATES were not allowed.
Compaq COBOL on Windows NT and on Tru64 UNIX issues a severe
run-time error if there is a mismatch, unless relax key checking (the
-rkc
flag) is specified, in which case the behavior is inconsistent. In many
cases, you will get the behavior of the specification when the file was
created, but you should not rely on this.
B.5.2 File Sharing and Record Locking
With Compaq COBOL on Windows NT and on Tru64 UNIX, certain
file-sharing and record-locking operations may behave differently from
the same operations on Compaq COBOL on OpenVMS Alpha. Compaq COBOL
on Windows NT and Tru64 UNIX issues warning diagnostics where
applicable.
- File sharing for sequential and relative files on all systems
remains essentially the same. One notable exception is REGARDLESS,
which is not supported on Windows NT systems.
- File sharing for indexed files has the following limitation: The
OPEN statement ALLOWING READERS phrase is minimally supported for
indexed files on Windows NT and Tru64 UNIX systems. Using the
ALLOWING READERS phrase for indexed files is not recommended.
- File-sharing protocols for all file organizations are in effect
for Windows NT and Tru64 UNIX systems for the OPEN statement in
OUTPUT mode, which is similar to EXTEND and I-O modes. On
Windows NT and Tru64 UNIX systems, access is denied or granted
depending on the file lock requested and the file lock held (with the
exception of the READERS support noted previously.) On OpenVMS Alpha,
a new version of the file is always created.
- Manual record locking for files with the indexed organization has
the following limitations:
- For the READ and START statements, the REGARDLESS phrase is not
fully supported. The read or start operation is performed but the soft
record lock status is not returned.
- The START statement does not detect or acquire a record lock.
- The READ statement with the ALLOWING READERS phrase is not
supported. It is treated as NO OTHERS if the file is opened in I-O mode
or it is treated as ALL if the file is opened in INPUT mode.
- The REWRITE and WRITE statements do not retain record locks.
- The (current) RECORD phrase is not supported for the UNLOCK
statement. The ALL RECORDS phrase is assumed for all UNLOCK statements.
B.5.3 VFC File Format
If a VFC file is created on OpenVMS Alpha and then read on
Windows NT or Tru64 UNIX, the data record will be returned with
the 2-byte control string in the data record when it is read.
The workaround is to convert the file to a non-VFC format on
OpenVMS Alpha. VFC files are created on OpenVMS Alpha by
Compaq COBOL for OpenVMS VAX and Compaq COBOL for the following:
LINAGE
REPORT WRITER
SEQUENTIAL EXTERNAL/GLOBAL
Output with WRITE ADVANCING
B.5.4 File Attribute Checking
Compaq COBOL on Tru64 UNIX and Windows NT systems provides
limited file attribute checking. No file attribute checking is
performed for sequential and relative files. For indexed files,
Compaq COBOL verifies that the following file attributes match what
is specified in the application:
- Number of keys
- Size and position (within the record structure) of each key
- Whether or not duplicates are allowed for each key
If these attributes are not matching, the file will not be opened and a
fatal runtime error will occur (or Declaratives will be invoked, if
applicable).
However, with the relax key checking option selected Compaq COBOL
will allow you to open a file which specifies fewer keys than were
specified when the file was originally created. This option will
provide correct results only in those cases where the unspecified keys
are USAGE DISPLAY (PIC X). Also,
-rkc
allows you to open a file which specifies DUPLICATES for a key in a way
differently from the specification given when the file was created.
There is an additional check in creating an indexed file: unless relax
key checking is specified, you may not have two keys that are identical
except for whether DUPLICATES are allowed. If this restriction is
violated, there will be an explicit run-time error message and those
operations that are affected by DUPLICATES may give unexpected results.
B.5.5 Indexed Files
Compaq COBOL on Tru64 UNIX and Windows NT treats indexed
files differently from the way they are treated by both Compaq COBOL
on OpenVMS Alpha and Compaq COBOL for OpenVMS VAX on OpenVMS Alpha. Specifically:
- For an indexed file, the run-time system creates two files on the
disk: one file with the dat extension, and the other file with the idx
extension. Additionally, on Windows NT a file with the lck
extension is created.
- If you try to open an indexed file as a sequential file, the key
part of any record other than a character key will be different. The
reason is that the keys in a record are translated to a file format on
disk.
- When you open an existing indexed file, the RTL checks its key
structure and returns a severe error if there is a serious mismatch.
On Windows NT and Tru64 UNIX, this RTL check does not
detect some differences that would be detected on an OpenVMS Alpha
system, because all but signed 16- and 32-bit integers are mapped onto
character strings. For example, if you write an indexed file using a
key described as an unsigned 32-bit integer, the character string you
will read is the integer with its bytes reversed. On an OpenVMS Alpha
system, by contrast, you receive a severe error when you try to open a
file with the incompatible key.
B.5.6 RMS Special Register References in Your Code
Compaq COBOL on Windows NT and Tru64 UNIX does not support
RMS Special Registers. If you include them, you may receive the
following general diagnostic message when you attempt to compile the
program:
cobol: Severe: ...Undefined name
|
B.5.7 Time and Fractional Seconds
Fractions of seconds are not handled by the Compaq COBOL runtime
library on Windows NT. The value zero is returned for those parts
which cannot be determined. This impacts the following:
ACCEPT FROM TIME
FUNCTION CURRENT-DATE
FUNCTION WHEN-COMPILED <>
B.6 File Compatibility Across Languages and Platforms
Files created by different programming languages may require special
processing because of language and character set incompatibilities. The
most common incompatibilities are data types and data record formats.
You should be aware of the following:
-
Print-controlled files that are created on Windows NT or the
Tru64 UNIX operating system cannot be used as VFC files on the OpenVMS Alpha operating system.
-
VFC files cannot be used on Windows NT or on the Tru64 UNIX operating system.
-
On Windows NT and Tru64 UNIX, to read a file with
variable-length records, you must describe the file as such in the
program (use RECORD IS VARYING). On OpenVMS Alpha, you can read a file
with variable-length records by using a file description for
fixed-length records.
-
On OpenVMS Alpha, a file with fixed-length records can be described in
a COBOL program with an FD specifying a length shorter than
the file record length. On input, the extra data in each record is
ignored on OpenVMS Alpha. On Windows NT and Tru64 UNIX, the
length specified for the FD must match the actual length of the records
in the file; you must not use RECORD IS VARYING to read a file
with fixed-length records.
-
On OpenVMS Alpha, an existing ORGANIZATION INDEXED file cannot be read
with an FD specifying ORGANIZATION SEQUENTIAL. To read the file on
Windows NT or Tru64 UNIX sequentially, use ORGANIZATION
INDEXED, ACCESS SEQUENTIAL (or DYNAMIC), and READ NEXT.
Data Type Differences
Data types vary by programming language and by utilities. For example,
Compaq Fortran does not support the packed-decimal data type and,
therefore, cannot easily use PACKED-DECIMAL data in COBOL
files.
You can use the following techniques to overcome data type
incompatibilities:
- Use the NATIVE character set, which uses ASCII representation, for
all data in files intended for use across languages.
- If your requirements include processing non-ASCII data, you can
specify a character set in: (1) the SPECIAL-NAMES paragraph of the
Environment Division, along with (2) the CODE-SET clause in the SELECT
statement. Except for NATIVE, you must specify all character sets in
the SPECIAL-NAMES paragraph.
- Use common numeric data types (numeric data types that remain
constant across the application).
In the following example, the input file is written in EBCDIC. This
creates a file that would be difficult to handle in most languages
other than COBOL on the OpenVMS Alpha operating system.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SPECIAL-NAMES. ALPHABET FOREIGN-CODE IS EBCDIC.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT INPUT-FILE ASSIGN TO "INPFIL"
CODE-SET IS FOREIGN-CODE.
.
.
.
|
B.7 LIB$INITIALIZE Interaction Between C and COBOL
If you use LIB$INITIALIZE when the main program is written in
Compaq COBOL and the initialize routine is written in Compaq C, the
initialize routine will not be called. If you are using Compaq COBOL for OpenVMS VAX
on OpenVMS VAX Version 7.1, however, the routine will be called; also,
it will be called if your main program is in C or in BASIC rather than
COBOL, so this can be a practical workaround.
The problem is due to the quadword alignment with which C creates the
LIB$INITIALIZE psect. The LIB$INITIALIZE psect requires longword
alignment. The programmer can explicitly specify longword alignment on
the extern_model pragma to avoid the problem.
B.8 Reserved Words
Depending on the use of the /RESERVED_WORDS qualifier or flag, there
are a number of additional reserved words in Compaq COBOL that are
not reserved in Compaq COBOL for OpenVMS VAX. See the appendix on
reserved words in the Compaq COBOL Reference Manual for complete information.
B.9 Debugger Support Differences
Compaq COBOL debugger support differs in several ways from
Compaq COBOL for OpenVMS VAX:
- Compaq COBOL issues the following informational message when the
/DEBUG qualifier is used on the COBOL command line with the
default optimization in effect:
%COBOL-I-DEBUGOPT, /NOOPTIMIZE is recommended with /DEBUG
|
You receive this message if you specify nothing about optimization
when you specify /DEBUG. (/OPTIMIZE is the default for the compiler.)
Unlike other informational messages, which are turned off by default,
this message is always allowed through by the Compaq COBOL compiler,
even if /WARN=NOINFO is in effect. To turn the message off, use any
form of the qualifier /[NO]OPTIMIZE on the COBOL command line (for
example, /NOOPTIMIZE or /OPTIMIZE or /OPTIMIZE=LEVEL=x).
- Compaq COBOL for OpenVMS VAX does not have the /OPTIMIZE qualifier.
- With Compaq COBOL, unlike Compaq COBOL for OpenVMS VAX, the debugger sometimes
changes underscores to hyphens and hyphens to underscores in variable
names.
This difference from Compaq COBOL for OpenVMS VAX can help you debug a program.
Because these messages are informational, the compiler produces an
object file, which you can link and execute. However, the messages may
point out otherwise undetected logic errors, as the structure of the
program is probably not what you intended.
B.10 DECset/LSE Support Differences
Compaq COBOL does not support the DECset/LSE Program Design Facility,
the /DESIGN qualifier, design comments, or pseudocode placeholders.
B.11 DBMS Support
On OpenVMS, Compaq COBOL support for Oracle DBMS has some
differences depending on your platform (specifically, whether you are
developing programs with Compaq COBOL on OpenVMS Alpha or with
Compaq COBOL for OpenVMS VAX). <>
B.11.1 Compiling on Tru64 UNIX and Windows NT
In Compaq COBOL for Windows NT or Tru64 UNIX, Oracle DBMS
sub-schema access (DML for Oracle DBMS) is not supported. Attempting
to compile a program containing any Oracle DBMS syntax results in
the following diagnostic message:
cobol: Severe: ...DBMS Data Manipulation Language is not supported
|
Oracle DBMS syntax includes the following language elements:
SUB-SCHEMA, DB, DB-EXCEPTION, LD, COMMIT, CONNECT, ERASE, FETCH, FIND,
FREE, GET, KEEP, MODIFY, READY, RECONNECT, ROLLBACK, STORE, RETAINING,
WHERE, EMPTY, MEMBER, OWNER, and TENANT.
You may also receive the following general diagnostic message when you
attempt to compile a program (on Tru64 UNIX) that contains
variables defined in your Oracle DBMS sub-schema:
cobol: Severe: ...Undefined name
|
B.11.2 Multistream DBMS DML
With Compaq COBOL, when you use multistream Oracle DBMS DML, you
must access different schemas or streams from separate source files.