EXTERNAL

Abbreviation: EXT

EXTERNAL is a scope attribute that specifies that the declared name has external scope. This means that all declarations of this name anywhere in the program that also have the EXTERNAL attribute identify the same object.

The EXTERNAL attribute can be used only in the declaration of variables whose storage class is STATIC or CONTROLLED. (It can be redundantly specified for variables of storage classes GLOBALDEF and GLOBALREF, which are implicitly EXTERNAL STATIC.) If EXTERNAL is specified for a variable and no storage class attribute is specified, STATIC is supplied by default. Its format is:

EXTERNAL[(global_name)]

global_name is either a character-string constant or a %REPLACE name for a character string constant. global_name is used by the linker when references are made to the entry. Open PL/I makes no restrictions on the contents of global_name, but the underlying operating system may have restrictions.

EXTERNAL must be specified when the entry is declared in another module. EXTERNAL(global_name) is specified as an option either on a PROCEDURE statement or on an ENTRY statement.

By using the EXTERNAL(global_name) option, an alternative name can be specified for an external entry constant. Instead of the usual entry constant name, the alternative name (global_name) is used to invoke the procedure at the entry point.

OZS: PROCEDURE;
      DECLARE PROC1 ENTRY;
      DECLARE ALSO_PROC1 ENTRY EXTERNAL('PROC1');
      DECLARE PROC2 ENTRY EXTERNAL('ILL.EGAL');
      CALL PROC1;
      CALL ALSO_PROC1;
      CALL PROC2;
      END OZS;

      /*======== A SEPARATE MODULE ========*/

      PROC1: PROCEDURE;

      PROC2: ENTRY EXTERNAL('ILL.EGAL'); 
      
      END PROC1;

In this example, the program declares explicitly the entry constants PROC1 and PROC2.