Compaq AAQ2G1FTK Marine Radio User Manual


 
Interprogram Communication
12.4 Accessing Another Programs Data Division
Values can also be returned through the BY REFERENCE parameter in the
USING phrase. However, the GIVING phrase uses the return value by immediate
value mechanism. Use of this mechanism requires that the GIVING result
(ITEMC) be an elementary integer numeric data item with COMP, COMP-1, or
COMP-2 usage and no scaling positions.
The RETURN-CODE special register provides an alternative mechanism for
returning a value from a called program to the calling program.
The order in which USING identifiers appear in both calling and called programs
determines the correspondence of single sets of data available to the called
subprogram. The correspondence is by position, not by name.
12.4.2 The Linkage Section
You must define each data name from the Procedure Division header’s USING
data name list in the called subprogram’s Linkage Section. For example:
LINKAGE SECTION.
01 PART PICTURE...
01 AMOUNT PICTURE...
01 INVOICE PICTURE...
01 COLOR PICTURE...
01 COST PICTURE...
PROCEDURE DIVISION USING PART, AMOUNT, COLOR, COST.
Of those data items you define in the Linkage Section, only those named in the
calling program’s Procedure Division header’s USING phrase are accessible to
the called program. In the previous example, INVOICE is not accessible from the
called program.
When a subprogram references a data name from the Procedure Division header’s
USING data name list, the subprogram processes it according to the definition in
its Linkage Section.
A called program’s Procedure Division can reference data names in its Linkage
Section only if it references one of the following:
Any data item named in the Procedure Division USING data-name-list
A data item that is subordinate to a Linkage Section data item in the
Procedure Division USING data-name-list
Any other association with a data item in the Procedure Division USING
data-name-list; for example, index-name, redefinition, and so on
In Figure 12–4, SUB is called by MAINPROG. Because MAINPROG names
FILE-RECORD and WORK-RECORD in its CALL ‘‘SUB’’ USING statement,
SUB can reference these data names just as if they were in its own Data
Division. However, SUB accesses these two data items with its own data names,
F-RECORD and W-RECORD.
1212 Interprogram Communication