The IS EXTERNAL clause declares that a data item is shared by two or more programs.
General Format
[ IS EXTERNAL ]
Syntax Rules
- Only level 01 and 77 data items in Working-Storage may be declared to be external.
- Each program that declares an external data item must use the same name for that item, and the item must occupy the same number
of bytes.
- External data items may not have a VALUE phrase.
- The IS EXTERNAL clause may not be used with the REDEFINES clause.
General Rules
- The phrase IS EXTERNAL must be included in the data description of the item in each program that accesses the item externally.
Each program of a run unit that declares an external data item may access that item. Any change to the item made by one program
is automatically seen by all the other programs. External data items may be shared between both COBOL and C programs.
- An external data item belongs to the run unit, not to any of the programs that are part of the run unit. This means that an
external data item is allocated for the duration of the run, regardless of the action of CANCEL verbs.
The one exception to this rule is external data items that are also C data items. These belong to the runtime system itself,
not to the run unit. The distinction is that you can initiate another run unit with the CALL RUN verb, but this does not initiate
another runtime system. In this case, you get new copies of the COBOL-only external data items, but keep the same data items
that are shared with C programs.
- Instructions for declaring a C data item external can be found in the file direct.c supplied with the runtime system. External data items may not have a VALUE phrase. They are initialized to binary zeros (NULL)
by the runtime.