The following program operations obtain access to files in libraries:
Files within libraries can be found only if the library is open. There are several ways to open a library:
Calling a filename without an extension causes all libraries currently opened to be searched for a program of that name. If the program is not found, and a library of that name exists, that library is opened. The program of that name within that library is run.
For example, if a library contains the program myprog.gnt, the root name of the library is also myprog, and there is no program outside of the library with the same name, then a CALL to myprog causes the library to be opened.
The library is left open, so it is added to the list of libraries which will be searched in a future CALL statement.
This opens library-name.lbr. It loads the catalog of the library into memory, thus making all the files and entry points that it contains available to the program.
The Directory Facility provides options for calling and canceling libraries explicitly. This can be useful during development and testing. See the chapter Directory Facility for details.
copy "textname.ext" of "library-name.lbr"
This opens library-name.lbr, reads textname.ext from it, and depending on the CANCELLBR directive, leaves it open for the rest of the compilation, so that the OF phrase can be omitted from the following COPY statements. See the topic CANCELLBR for information on CANCELLBR.
If the program is compiled with the COPYLBR directive, then:
copy "textname.ext" of "library-name"
is equivalent to the above, since this directive tells the Compiler that the name after OF in a COPY statement is a library-name , not a path.
path/library-name.lbr/filename.ext
This opens library-name.lbr on path and takes filename.ext from it. If the library does not exist or does not contain the file, a file not found error is returned.
However, we strongly recommend that your applications are not designed to depend upon this behavior.
cancel "library-name.lbr"
or a STOP RUN is executed. If any programs from the library file are in memory when the library file is canceled they remain in memory until they too are canceled.
This restriction also applies to data files which reside in library files. If you cancel a library file that contains a data file which is currently open, and perform further file operations on that file, the results are unpredictable.