INITIAL Clause

The INITIAL clause in the PROGRAM-ID paragraph causes a subprogram to be automatically canceled whenever it exits. The program is removed from memory, regardless of whether the logical cancel feature is enabled. This can be used to help manage memory or to ensure that VALUE clauses are set whenever a subprogram is called. Note that the compiler will automatically apply this clause to a program compiled with the -Zi option. This can be particularly useful when you are converting programs from RM/COBOL version 2.

In RM/COBOL, the status of a program that exits is not precisely defined. Subprograms remain in memory until either their caller exits or until inadequate memory remains to load another subprogram. This occurs at fairly unpredictable times. Because their fate in memory is unclear, most RM/COBOL subprograms are treated as if they have been canceled when they exit. By applying the -Zi option at compile time, the ACUCOBOL-GT programmer can simulate this behavior. Note, however, that utility subprograms that are called repeatedly should not be compiled with -Zi, because this introduces extra overhead each time they are called. Also, any subprogram that depends on retaining variables between calls should not be compiled with -Zi.

Note: RM/COBOL treats spooled print files specially in that they are not closed when a subprogram exits (all other files are closed). ACUCOBOL-GT does not treat spooled files specially, so if this feature of RM/COBOL is used, the subprogram that does this should not be compiled with -Zi.