|Forms-2||On-line Help System|
This chapter describes the Library utility, which groups individual files into one file. You also can use Library to group together static source code to create copylibraries.
Using Library gives you the following advantages:
Whole suites of programs and/or sets of data files can be stored in one library file.
Once the library file is opened, all the files it contains are readily accessible. You access data files in libraries by the usual OPEN, READ, and CLOSE statements; OPEN and CLOSE become logical operations handled by the run-time system rather than the more time consuming physical operations.
When you change directory you can still access files in a library in the original directory because the library catalog remains in memory.
If an application contains a call to a library not currently on the logged-on drive and the library has been built into your program, the system prompts you to insert the .lbr file.
Warning: Files in libraries are read-only; you cannot access them via WRITE or REWRITE. Trying to open such a file using OPEN OUTPUT or OPEN I-O will open a file outside the library, then WRITE or REWRITE will update this file leaving the file in the library unchanged.
Library is invoked from the operating system command line and runs in batch mode. The following sections describe how to invoke Library, how to create a Library batch file and how to access files in libraries.
To invoke Library, enter:
library file-name-1 [file-name-2...] [==library-name]
where the parameters are:
||Either a file to be included in the library, a library whose contents are to be included, or a library batch file (see below).|
||The library to be saved. If this is not
specified the library, takes the name of the first parameter, thus
can include drive and/or path. If these are unspecified the current
directory is assumed.
If you specify a .lbr library file as a
the new library includes all the files contained in the old library.
For libraries that you are going to create and recreate frequently, you can write a library batch file (.lbt file) which contains the list of files to be included in the library. See the section Creating a Library Batch File below.
If an overlayed program is in a library, all the overlays must be in the same library as the program root segment.
file-name can include a library name as
part of the path, you can use the Library Utility to copy files from one
or more existing libraries into a new library. This is especially useful
if you need to ship an application program that uses files supplied in
utils.lbr; you can copy the necessary files from
utils.lbr into a library of your own to ship with your
application program. You must give the name of the new library by using
library $COBDIR/utils.lbr/linein.gnt == mylib.lbr
Batch files can be used with the load function to save you entering file-names individually. To create a batch file, enter the COBOL Editor; type one file-name on each line in the file starting at column one; then save the file using a .lbt extension. This file contains the file-names only, not the actual files.
To run a library batch file, enter:
library batch.lbt == library-name
where the parameters are:
||The file you have just created, containing the list of files to be included in the library.|
||As described previously. However, in this
case, if you do not specify,
You can prefix any of the file-names with a path-name identifier.
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 file-name 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.
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"
from it, and depending on the
CANCELLBR directive (see your Object COBOL User Guide)
leaves it open for the rest of the compilation, so that the OF phrase
can be omitted from the following COPY statements.
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
not a path.
file-name.ext from it. If the library does not
exist or does not contain the file, a file not found error is
However, we strongly recommend that your applications are not designed to depend upon this behavior.
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.
Copyright © 1999 MERANT International Limited. All rights reserved.
This document and the proprietary marks and names used herein are protected by international law.
|Forms-2||On-line Help System|