COBOL Manual for TNS/E Programs (H06.03+)
Issues Related to Linking
HP COBOL Manual for TNS/E Programs—520347-003
24-9
Linking Automatically
Establishing a Mnemonic Name for an Object File
If a CALL or ENTER statement contains a mnemonic name that specifies the object file
that contains the called program, the compiler searches that file (and only that file) for
the specified routine. If the compiler does not find the routine, it reports an error.
You establish a mnemonic name for an object file with a File-Mnemonic clause in the
SPECIAL-NAMES paragraph of the Environment Division. Suppose that the object file
has the system file name MYLIB and you want to give it the mnemonic name HERLIB.
The File-Mnemonic clause is:
FILE "MYLIB" IS HERLIB.
Suppose that MYLIB contains a COBOL program named APROG. Your HP COBOL
program can call APROG with the statement:
CALL "APROG" OF HERLIB.
Quotation marks around the program name (APROG) are not required, but are
recommended. If, in some eventual program maintenance, someone adds a variable
named APROG to a program that already calls a program named APROG, and the
name APROG is not in quotation marks, the compiler assumes that APROG refers to
the variable. At run time, if the variable APROG does not contain the name of a valid
program that is included in the object file, the program terminates with the error
message “Called program not found.” If APROG is enclosed in quotes, the compiler
recognizes it as a program name rather than a variable.
Putting an Object File on the Primary Search List
If a CALL or ENTER statement does not contain a mnemonic name that specifies the
object file that contains the called program, the compiler searches for the called routine
in the object files on the primary search list. If the compiler finds the routine, it
validates the routine’s actual parameters and includes the entire object file (from the
primary search list) in the object file that it is creating.
You can put one or more object files on the primary search list with one or more
SEARCH directives. The first SEARCH directive establishes the primary search list
and adds files to it in the specified order. Subsequent SEARCH directives append files
to the primary search list in the specified order. The compiler searches the object files
of the primary search list in order. If the compiler finds the routine, it stops searching for
it.
If you put a SEARCH directive on the compilation command line when you compile
your program, the compiler sees that SEARCH directive first, so the primary search list
begins with that SEARCH directive’s object files.










