COBOL Manual for TNS and TNS/R Programs
Program Compilation
HP COBOL Manual for TNS and TNS/R Programs—522555-006
11-3
Main Programs
Main Programs
A main program is either compiled with the MAIN directive (see MAIN) or it has no
Linkage Section (see Absent Linkage Section). A loadfile must contain exactly one
main program. It can also contain other programs. When the loadfile is executed, the
NonStop operating system calls the main program. Then the main program can call the
other programs and the other programs can call each other. The NonStop operating
system does not call the other programs.
In Example 11-1, the MAIN directive makes A-PROGRAM a main program. If
A-PROGRAM and A-FRIEND are compiled in the same compilation unit, A-FRIEND is
not a main program. If A-FRIEND is compiled alone, it is a main program, because it
does not have a Linkage Section.
Example 11-1. Main Program and Another Program
?MAIN A-PROGRAM
IDENTIFICATION DIVISION.
PROGRAM-ID. A-PROGRAM.
ENVIRONMENT DIVISION.
...
SPECIAL-NAMES.
FILE "$SYSTEM.COBSYS.BFILES" IS B-FILE.
DATA DIVISION.
...
PROCEDURE DIVISION.
...
CALL "A-FRIEND"
...
CALL "B-FRIEND" IN B-FILE
...
STOP RUN.
END PROGRAM A-PROGRAM.
IDENTIFICATION DIVISION.
PROGRAM-ID. A-FRIEND.
ENVIRONMENT DIVISION.
...
SPECIAL-NAMES.
FILE "$SYSTEM.COBSYS.BFILES" IS B-FILE,
FILE "$SYSTEM.TALSYS.TFILES" IS T-FILE.
DATA DIVISION.
...
PROCEDURE DIVISION.
...
CALL "HOME" IN BFILE
...
ENTER TAL "SPECIALIST" IN T-FILE
...
STOP RUN.
END PROGRAM A-FRIEND.