Previous Topic Next topic Print topic


Accessing Files in Libraries

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:

Note:
  • If you create a library while working in 64-bit mode, the library cannot be used by the 32-bit version of Library, nor by a 32-bit application. Similarly, a 32-bit library file, created in 32-bit mode or using an earlier version of Server Express or Object COBOL Developer Suite, cannot be used by the 64-bit version of Library, nor by a 64-bit application.
  • Attempting to open a library that is already open has no effect.
  • If you open a data file for input, and do not specify a device, all libraries currently open are searched. If you do specify a device, that device only is searched; libraries are not searched. This applies both to files declared using COBOL syntax and to byte-stream files (see the chapter Byte-stream File Handling in your Library Routines).
  • If multiple libraries are called, and each library contains a program of the same name, if that program is subsequently called, the copy of the program in the last library called is loaded and run. For example, if you call liba.lbr, libb.lbr, and libc.lbr, all of which contain the program myprog.gnt, and then call myprog.gnt, the copy in libc.lbr is loaded and run.

    However, we strongly recommend that your applications are not designed to depend upon this behavior.

  • Once open, a library file remains open until it is canceled by the statement:
    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.

  • If any programs in the library file have been called, and the library file is then canceled, load failures may result if the run-time system has to remove the called program from memory and then has to reload it. As the library file has been canceled, the run-time system is not able to find the program.

    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.

Previous Topic Next topic Print topic