Library (statement)

From BR Wiki
(Redirected from Library statement)
Jump to navigation Jump to search

The Library statement is used in conjuction with the Library Facility to allow one program to access and use User Defined Functions from other programs.

Comments and Examples

To use the LIBRARY statement, first the function must be defined in a program and then identified. To qualify as a library function, a user-defined function must simply utilize the DEF statement's LIBRARY keyword. The following is an example of a library function definition:

52400 DEF LIBRARY FNPRESLIB2
52500 PRINT "This is a library function"
52600 FNEND

Executing a library function is a two-step process. First, the program executing the library function must name the function in a LIBRARY statement, which establishes either named or unnamed linkage. Second, the program must call the library function; this may be accomplished using any of the same methods that is available for calling other user-defined functions. In the following example, line 01000 uses the LIBRARY statement to establish named linkage between the function FNPRESLIB2 and the library PRESLIB. Line 01100 causes the library PRESLIB to be loaded into present memory (if the library does not already exist in memory), then executes FNPRESLIB2.

01000 LIBRARY "PRESLIB": FNPRESLIB2
01100 LET FNPRESLIB2

Syntax

LIBRARY [RELEASE] [,NOFILES] "<library name>":<function name> 

Parameters

The "Library Name" refers to the program, or library, where the library function has been defined. It must be enclosed in quotation marks.

Following a colon, the Function Name is simply the name of the function to be used.

A library initiated with NOFILES has it's own file set, and calls to it do not inherit any open channels. Each program library statement either indicates NOFILES or defaults to FILES. A library that is active as NOFILES cannot be passed files and vice versa. A library that is passed two different sets of files (by separate calls) simply works with what it is passed.

When LIBRARY NOFILES is specified, a separate console (window #0) is also created to service the library. The new console's size and properties are taken from the initiator's current console. This new console does not become visible until a program attempts to await operator input. Each NOFILES library has its own console regardless of GUI state.

When a LIBRARY statement is processed without the NOFILES parameter then a new console is not created and screen operations pertain to the caller's window hierarchy.

Inactive RELEASEd modules can be linked in either NOFILES mode (defaulting to FILES or specifying NOFILES) irrespective of previous modes of use and whether or not they were loaded resident.

See also the NoFiles parameter.

See Also