Compaq AAQ2G1FTK Marine Radio User Manual


 
Interprogram Communication
12.4 Accessing Another Programs Data Division
Figure 123 Accessing Another Programs Data Division
IDENTIFICATION DIVISION.
PROGRAMID. SUB.
ENVIRONMENT DIVISION.
DATA DIVISION.
LINKAGE SECTION.
01 PART PICTURE X.
01 AMOUNT PICTURE 9.
01 COST PICTURE 99.
01 COLOR PICTURE XX.
PROCEDURE DIVISION USING PART,
SUBSTARTUP.
AMOUNT,
.
.
.
COLOR,
.
.
.
COST.
EXIT PROGRAM.
IDENTIFICATION DIVISION.
PROGRAMID. MAINPROG.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKINGSTORAGE SECTION.
PROCEDURE DIVISION.
01 A PICTURE X.
01 B PICTURE 9.
01 C PICTURE XX.
01 D PICTURE 99.
.
.
.
CALL "SUB" USING A, B, C, D.
STARTUP.
.
.
.
STOP RUN.
1
4
2
3
ZK1731GE
In Figure 12–3, when execution control transfers to SUB, it can access the four
data items in the calling program by referring to the data names in its Procedure
Division USING phrase. For example, the data names correspond as follows:
Data Name in
MAINPROG
(Calling Program)
Corresponding Data Name in SUB
(Called Subprogram)
A PART
B AMOUNT
C COLOR
D COST
The CALL statement can make data available to the called program by the
following argument-passing mechanisms:
REFERENCE—The address of (pointer to) the argument (arg) is passed to
the calling program. This is the default mechanism.
CONTENT—The address of a copy of the contents of arg is passed to the
called program. Note that since a copy of the data is passed, the called
program cannot change the original calling program data.
VALUE—The value of arg is passed to the called program. If arg is a data
name, its description in the Data Division can be as follows: ( a ) COMP usage
with no scaling positions (the PICTURE clause can specify no more than nine
digits) and ( b ) COMP-1 usage.
1210 Interprogram Communication