Features for Backward Compatibility [ COBOL/HP-UX Operating Guide for the Series 700 and 800 ] MPE/iX 5.0 Documentation
COBOL/HP-UX Operating Guide for the Series 700 and 800
Features for Backward Compatibility
The following sections describe features of the Micro Focus COBOL system
which are supported in this release for compatibility purposes with
previous releases of the system. You are not recommended to use them in
new applications.
Calling Non-COBOL Subprograms
The Micro Focus COBOL system allows you to call non-COBOL subprograms by
using the standard COBOL CALL statement. However, for compatibility with
existing Micro Focus COBOL products, you also can call a non-COBOL
subprogram by supplying a numeric value, which is interpreted by the RTS
as an index into its run-time subprogram table. The RTS uses this table
entry to locate the object code of the called subprogram, which may have
been written in C or some other language. For example:
CALL "7" USING...
or:
CALL SPR-INDEX USING...
where SPR-INDEX is an alphanumeric item whose value is a valid run-time
subprogram table index.
Before you can call such subprograms, you must incorporate them into the
RTS.
Incorporating Non-COBOL Subprograms into the RTS.
The issued software includes, in libcobol.a,
all of the modules necessary to create a standalone COBOL RTS which
includes a dummy version of the run-time subprogram table. The source of
the run-time subprogram table is also supplied in usercall.c.
To incorporate a non-COBOL subprogram into the RTS:
1. Modify usercall.c
to create an entry for the subprogram in the RTS run-time
subprogram table. See below for a detailed description of how to
do this.
2. Include usercall.c on the cob command line. For example:
cob -xo rts32 -e "" prog1.cbl prog2.cbl usercall.c
See Chapter 2 , COBOL System Interface for details on using the
cob command.
3. You must move the user RTS to /usr/lib/cobol/, or to the directory
pointed to by the COBDIR environment variable, where it can be
accessed by cobrun (see Chapter 7 , Running).
Modifying the Run-Time Subprogram Table.
The module usercall.c contains a function xequcall( ).
It is this function that you must modify to incorporate a subprogram into
the RTS.
The xequcall( ) function consists of a single switch statement, where
each case clause in the switch corresponds to a single subprogram
incorporated in the RTS. Incorporating a new subprogram effectively means
adding a new case clause to the switch in xequcall( ). However, before
updating the switch in xequcall( ), you must understand how the RTS
handles CALL and the parameters passed with it.
The CALL Mechanism
When the RTS processes a CALL, it goes through an internal CALL executor,
which determines the type of call and accesses the appropriate table to
find the routine. All of the arguments following USING are COBOL data
names. The absolute addresses of these items are placed in the global
calargv[ ] array,
and the count is assigned to calargc.
These are analogous to the argv/argc structure with which a C program is
invoked. For instance, if a COBOL program included the following
sentence:
CALL "1" USING A, B.
then calargv[0] would contain the address of data item A, calargv[1]
would contain the address of data item B, and calargc would have the
value 2. The data items may be numeric or alphanumeric strings. Note
that if you use COMP variables, you must be aware that the
byte order may differ from that of the machine. In COBOL, the highest
order byte is always first.
If the CALL parameter is numeric, as in the example above, this indicates
that the call is to a user routine in the RTS, rather than to another
COBOL program, and the xequcall( ) function is called.
Non-COBOL Programs Calling COBOL Subprograms
Under previous Micro Focus COBOL products you had to use cobcall
when calling a COBOL subprogram from a program written in a language
other than COBOL. cobcall is still supported by the Micro Focus COBOL
system but, for compatibility purposes only. See Appendix A ,
Advanced Programming Features for details of how you can call a COBOL
program from a non-COBOL one under Micro Focus COBOL.
COBOL Capabilities File (cobcap)
In this release of the Micro Focus COBOL system, file-name mapping allows
you to make use of advanced file assignment facilities (see Chapter 12
, COBOL File Handling for details). In previous versions of the Micro
Focus COBOL system, such file assignment facilities were handled by the
COBOL capabilities file, cobcap. cobcap is still supported in the
current Micro Focus COBOL system for compatibility purposes.
COBCTRLCHAR Environment Variable
Earlier Micro Focus COBOL products achieved the displaying of certain
attributes on the screen by displaying Escape sequences. In this version
of Micro Focus COBOL, this is not supported as this has been replaced
with extended ACCEPT and DISPLAY syntax. This syntax is described in
your Language Reference. However, if for compatibility reasons it is
necessary for you to display Escape sequences, you can do so by
displaying the control code for the required attribute. When doing this,
you must ensure that the COBCTRLCHAR environment variable is set to Y.
Since displaying control codes imposes a severe performance restriction,
you are strongly advised to use the extended ACCEPT and DISPLAY syntax
instead.
Additionally, COBCTRLCHAR imposes a number of restrictions:
* Programs containing Escape sequences cannot be animated.
* Automatic new line handling is not supported and all output goes
directly to the terminal. It is, therefore, your responsibility
either to use explicit cursor addressing, or to ensure that the
correct control codes are output for that particular terminal in
your particular configuration.
Commands to Invoke the Micro Focus COBOL System Components
In this release of the Micro Focus COBOL system, access to the various
components of the COBOL compilation system is via a single command - the
cob command. This is described fully in Chapter 2 , COBOL System
Interface. In previous releases of Micro Focus COBOL systems each
component was invoked via its own command:
* the cobol command - to invoke the compiler
* the cgen command - to invoke the native code generator
In previous releases of Micro Focus COBOL systems, if you failed to
specify a file extension for the files input to these commands, cobol
assumed the extension .cbl, cgen the extension .int. Although these
commands are still supported under the current version of the Micro Focus
COBOL system, you must specify file extensions explicitly. The cobol and
cgen commands supplied with this product do not assume any file
extensions if you fail to specify them.
You must also note that the default list of compiler and native code
generator directives set by the cobol and cgen commands, is not the same
as that set by cob. The cobol and cgen commands are provided for
compatibility with LEVEL II COBOL/ET. You are recommended not to use
these commands, but if you want to do so, you should refer to your LEVEL
II COBOL/ET documentation. See Appendix G , Directives for
Compiler/Generator for details of the default directives set by cob.
You are recommended to use the cob command in preference to the cobol and
cgen commands.
Optimizing Intermediate Code
Operating Guides for existing Micro Focus products, such as LEVEL II
COBOL/ET, contain a section which describes how to optimize intermediate
code. Although the constructs described in this section are still true
for the Micro Focus COBOL system, you are advised to optimize your native
code versions of your programs rather than the intermediate code
versions.
Where arithmetic statements conform to the guidelines given in
previous operating guides, the resulting intermediate code is called
comp(utational) subset code. Comp subset code is more efficient than
intermediate code produced from arithmetic statements not conforming to
the guidelines.
However, in this version of Micro Focus COBOL, you do not need to produce
comp subset code, because generating your code will make it as efficient
as it can be. Arithmetic statements are not made any more efficient by
comp subset code. For this reason, this operating guide does not include
the guidelines for producing comp subset code.
MPE/iX 5.0 Documentation