Library part
A library part contains a set of functions, variables, and constants that can be used by programs, page handlers, or other libraries. It is recommended that you use libraries to maximize your reuse of common code and values.
Rules are as follows:
- You can reference a library's functions, variables, and constants without specifying the library name, but only if you include the library in a program-specific Use declaration.
- Library functions can access any system variables that are associated with the invoking program or page handler. The following restrictions apply:
- When a function in a library receives a record as an argument, the record cannot be used for input or output (I/O) or for testing an I/O state such as endOfFile. The code that invokes the library, however, can use the record in either way.
- When you declare a record in a library, the library-based functions can use the record for input or output (I/O) and for testing the I/O state (for end of file, for example). The code that invokes the library, however, cannot use the record in either way.
- Library functions can use any statements except these:
- converse
- forward
- show
- transfer
- A library cannot access a text form.
- A library that accesses a print form must include a use declaration for the related form group.
- You can use the modifier private on a function, variable, or constant declaration to keep the element from being used outside the library.
- Library functions that are declared as public (as is the default) are available outside the library and cannot have parameters that are of a loose type, which is a special kind of primitive type that is available only if you wish the parameter to accept a range of argument lengths. For details on the loose type, see Function part in EGL source format.
The library is generated separately from the parts that use it. At run time, the library is loaded when first used and is unloaded when the program or page handler that accessed the library leaves memory, as occurs when the run unit ends or when a program (if segmented) issues a converse statement. .
A page handler gets a new copy of the library whenever the page handler is loaded. Also, a library that is invoked by another library remains in memory as long as the invoking library does.
A library that is used only for its constants is not loaded at run time because constants are generated as literals in the programs and page handlers that reference them.
Related reference
converse
forward
Function part in EGL source format
Library part in EGL source format
Run unit
Segmentation in text applications
show
transfer
Use declaration