Search Conventions Used for Calling Programs

Restriction: This information is not applicable to .NET managed code.

When a program is called, the run-time system checks to see if the program has already been loaded or logically canceled. If the program is already available in memory, the run-time system passes control to it.

If the program is not available, the run-time system searches for it first in the current directory, then the directory containing the calling program, and then the directories set in the COBDIR environment variable.

The search sequence described here applies to executable files (programs). It does not apply to other file types, for example data files and COBOL source files. Also, you don't need to be concerned in this discussion if you have only one executable version of your program on disk.

The run-time system first looks in the current directory for the called program. If the called program is named explicitly, (its name and its extension are specified), the specific executable file is searched for. If the called program is named implicitly, (only its base name and not its extension is specified) the run-time system looks for executable files in the order:

  1. filename.gnt
  2. filename.int
  3. filename.lbr
  4. filename.so
  5. filename

If the called program is not found in the current directory, the run-time system repeats the search in the calling program's directory, and then in each directory specified by COBDIR. If it reaches the last directory without finding an executable file, the run-time system issues a "program not found" error message.

This is the default behavior of the run-time system; you can change the search order using the Configure Application Environment dialog.

In the case of a library file, the run-time system opens it, and searches it for an executable name filename.ext where .ext is one of the other executable file types listed above.

Note:

If the dollar sign ($) is the first character of a program name, and that program is dynamically linked, or dynamically loadable, the first element of the program name is checked for filename mapping. The first element of the program name consists of all the characters before the first backslash character (\). For example, if the source program contains the statement:

 CALL "$MYLIB\A"

the subprogram A is loaded from the path as defined by the MYLIB environment variable when the program is run.