Interprogram Communication
12.4 Accessing Another Program’s Data Division
•
On OpenVMS, DESCRIPTOR—The address of (pointer to) the data item’s
descriptor is passed to the called program.
♦
(Note that BY DESCRIPTOR is not supported by Tru64 UNIX. See Compaq
COBOL Reference Manual, the CALL statement.)
•
OMITTED—A value equivalent to BY VALUE 0 is passed to the called
program. Note that OMITTED does not change the default mechanism.
Note
A called COBOL subprogram must have arguments passed to it using
BY REFERENCE, which is the default, or BY CONTENT. BY VALUE,
OMITTED, and BY DESCRIPTOR are Compaq extensions and will not
work as expected if passed to a COBOL program. These argument-
passing mechanisms are necessary when calling Run-Time Library
Routines and system service routines as described in Chapter 13.
The mechanism for each argument in the CALL statement USING phrase
must be the same as the mechanism for each argument in the called program’s
parameter list.
If the BY REFERENCE phrase is either specified or implied for a parameter,
the called program references the same storage area for the data item as the
calling program. This mechanism ensures that the contents of the parameter in
the calling program are always identical to the contents of the parameter in the
called program.
If the BY CONTENT phrase is either specified or implied for a parameter, only
the initial value of the parameter is made available to the called program.
The called program references a separate storage area for the data item. This
mechanism ensures that the called program cannot change the contents of the
parameter in the calling program’s USING phrase. However, the called program
can change the value of the data item referenced by the corresponding data name
in the called program’s Procedure Division header.
Once a mechanism is established in a CALL statement, successive arguments
default to the established mechanism until a new mechanism is used. For
example:
CALL "TESTPRO" USING ITEM-A
BY VALUE ITEM-B
Note that ITEM-A is passed using the BY REFERENCE phrase and that ITEM-B
is passed using the BY VALUE phrase.
If the OMITTED phrase is specified for a parameter, the established call
mechanism does not change.
One other mechanism of the CALL verb is the ability to use a GIVING phrase in
the CALL statement. This allows the subprogram to return a value through the
data item in the GIVING phrase. For example:
CALL "FUNCTION" USING ITEMA ITEMB
GIVING ITEMC.
Interprogram Communication 12–11
Содержание COBOL AAQ2G1FTK
Страница 22: ......
Страница 30: ......
Страница 94: ......
Страница 110: ......
Страница 146: ......
Страница 180: ......
Страница 194: ...Processing Files and Records 6 1 Defi...
Страница 300: ......
Страница 490: ......
Страница 516: ......
Страница 517: ......
Страница 530: ......
Страница 534: ......
Страница 590: ......
Страница 620: ......