The EXPORT declaration declares procedures in a library program to be entry points into that library. A procedure that is declared as an entry point into a library can be accessed by programs external to the library.
<export declaration>
── EXPORT ─┬───────────────────────────────────────────────────┬───────►
│ ┌◄────────────────── , ─────────────────┐ │
└─ [ ─┴─┬─/1\─ PROTECTED ───<linkage class──┬─┴─ ] ─┘
└─<library object access mode>──────┘
┌◄────────────── , ─────────────┐
►─┴─<export object specification>─┴────────────────────────────────────┤<export object specification>
──┬─<array identifier>─────────────────────┬─┬────────────────────┬────┤ ├─<array reference identifier>───────────┤ └─<export qualifier>─┘ ├─<event array identifier>───────────────┤ ├─<event identifier>─────────────────────┤ ├─<interlock array identifier>───────────┤ ├─<interlock identifier>─────────────────┤ ├─<non-array data identifier>────────────┤ ├─<procedure identifier>─────────────────┤ └─<procedure reference array identifier>─┘
<export qualifier>
──┬───────────────────────────────┬─┬──────────────────┬───────────────┤ └─ AS ──<EBCDIC string literal>─┘ └─<export options>─┘
<export options>
┌◄────────────────── , ──────────────────┐
── ( ─┴─┬─/1\─ LINKCLASS ── = ─┬─ PROTECTED ─┬─┴─ ) ───────────────────┤
│ └─<integer>───┤
└─<library object access mode>───────┘<EBCDIC string literal>
┌◄──────────────────────────────────────────────┐
──┴─┬───────────────┬─ " ──<EBCDIC string>── " ─┬─┴────────────────────┤
├─<EBCDIC code>─┘ │
├─ 48 ──┬─ " ──<hexadecimal string>── " ────┤
├─ 480 ─┘ │
├─ 28 ──┬─ " ──<quaternary string>── " ─────┤
├─ 280 ─┘ │
├─ 18 ──┬─ " ──<binary string>── " ─────────┘
└─ 180 ─┘
──┬─<Boolean identifier>──┬────────────────────────────────────────────┤ ├─<complex identifier>──┤ ├─<dinteger identifier>─┤ ├─<double identifier>───┤ ├─<integer identifier>──┤ └─<real identifier>─────┘
──/1\──┬─ READONLY ──┬─────────────────────────────────────────────────┤
└─ READWRITE ─┘──<constant arithmetic expression>─────────────────────────────────────┤
All procedures to be exported must be declared before the appearance of the EXPORT declaration and must be declared in the same block as the EXPORT declaration. All data to be exported must be declared no later than the appearance of the EXPORT declaration and must be declared in the same block as the EXPORT declaration.
A program can give an exported access mode to an exported data library object by specifying a <library object access mode>. A <library object access mode> can be specified only for data library objects. Data library objects include <non-array data identifier>s and <data array identifier>s. The READONLY option indicates that the exporter is allowing read-only access to the data. The READWRITE option indicates that the exporter is allowing both read and write access to the data. The access mode, if not specified, defaults to READONLY. An exported access mode is not allowed for an EVENT, an EVENT ARRAY, an INTERLOCK, or an INTERLOCK ARRAY. If all the library objects in the EXPORT declaration are data library objects and they all have the same access mode, the access mode can be specified in the square brackets just after the EXPORT keyword.
Multidimensional arrays can be included in an EXPORT declaration if they are specified with a READWRITE access mode.
A program can export an array row by specifying the name of the array, which was declared with one dimension, as an <array identifier> in the EXPORT declaration. No bounds should be specified. A multi-dimensioned array cannot be exported, but array row equivalence can be used to export one of its rows. Value arrays cannot be exported, but array references can be exported, and the array reference can be assigned the value array in an array reference assignment.
To provide a library object with a security level, the object can be exported with a linkage class assigned to it. The linkage class of the user program, which is assigned by the system, is matched to the linkage class of the exported object on a per object basis to determine if visibility is allowed to the calling program. The PROTECTED linkage class specifies the level of security. The values 0 through 15 can be assigned. The default linkage class is 0, which provides the lowest level of security. The <linkage class> from an arithmetic expression must resolve to a constant integer value. The evaluated constant arithmetic expression must be within the integers 0 to 15, inclusive.
A procedure reference array can be exported. Any type or parameters allowed for an exported procedure can be reference by an exported procedure reference array.
A program becomes a library by exporting procedures and then executing a FREEZE statement. The code file for that program contains a structure called a library directory, which describes the library and its entry points. The directory description of an entry point includes the entry point's name, a description of the procedure's type, if any, and descriptions of its parameters.
When a program calls a library entry point, the description of the entry point in the library template of the calling program is compared to the description of the entry point of the same name in the library directory of the library. If the called entry point does not exist in the library or if the two entry point descriptions are not compatible, a run-time error is given and the calling program is terminated.
The name given to an exported entry point in a library directory is the procedure identifier from the EXPORT declaration, unless an AS clause appears, in which case the name is given by the EBCDIC string literal.
The EBCDIC string literal in the AS clause can contain only valid <printable character>s, but must not contain any leading, trailing, or embedded blanks or periods. The entry point name indicated by this string literal will be case sensitive.

