Microsoft KB Archive/61348

CANCEL Does Not Remove COBOL Subprogram Without EXIT PROGRAM

PSS ID Number: Q61348 Article last modified on 05-02-1990

3.00 3.00a MS-DOS

Summary: The CANCEL statement is designed to remove a dynamically CALLed subprogram from memory. However, CANCEL will not remove a COBOL subprogram from memory unless the CALLed program explicitly executes an EXIT PROGRAM statement. CANCEL will not remove a subprogram from memory if EXIT is used instead of EXIT PROGRAM. This information applies to Microsoft COBOL versions 3.00 and 3.00a for MS-DOS.

More Information: There are two ways to leave a CALLed subprogram. You can execute an EXIT statement, or you can execute an EXIT PROGRAM statement. However, even though the EXIT statement causes a subprogram to exit back to the CALLing program, the EXIT statement was not designed specifically for ending a CALLed subprogram. The EXIT statement was originally designed to give an EXIT point for a logical group of PERFORMed statements or to a SECTION. For example, you must use an EXIT statement to exit the INPUT and OUTPUT SECTIONs during a SORT when those SECTIONs have completed their work. The correct way to end a CALLed subprogram is with the EXIT PROGRAM statement. CANCEL will not remove a CALLed subprogram from memory unless that program is terminated with an EXIT PROGRAM statement. If many subprograms are CALLed and EXIT is incorrectly used for EXIT PROGRAM, COBOL will eventually generate run-time error 198, “Load failure.”

Copyright Microsoft Corporation 1990.