Microsoft KB Archive/37881

From BetaArchive Wiki
< Microsoft KB Archive
Revision as of 19:21, 12 August 2020 by X010 (talk | contribs) (X010 moved page Microsoft KB Archive/Q37881 to Microsoft KB Archive/37881 without leaving a redirect: Text replacement - "Microsoft KB Archive/Q" to "Microsoft KB Archive/")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

CANCEL Must Cancel the PROGRAM-ID of the Called Program

PSS ID Number: Q37881 Article last modified on 04-20-1993

3.00 3.00a | 3.00 3.00a MS-DOS | OS/2

The information in this article applies to:
- Microsoft COBOL for MS-DOS and OS/2, versions 3.0 and 3.0a

Summary: When a dynamic Microsoft COBOL Version 3.0 or 3.0a subprogram is CALLed and exited, the subprogram should subsequently be CANCELled using the subprogram’s PROGRAM-ID value. If the subprogram is not CANCELled or it is CANCELled using its different .EXE filename, it remains in memory and can eventually cause a load error, such as the following: Failed to load program <subname> Run time error number: 198 The program will return to the MS-DOS prompt.

More Information: In the example below, the subprogram will not be unloaded from memory if the “driver” program CANCELs the .EXE subprogram filename instead of the PROGRAM-ID name. If the CANCEL statement is changed to look like CANCEL “PASSENGER”, it should then unload and free memory as expected. Other than ANS85, these programs can be compiled with most any directive.

Code Example

Program name “DRIVER.CBL”: $SET ANS85 IDENTIFICATION DIVISION. PROGRAM-ID. DRIVER. DATA DIVISION. WORKING-STORAGE SECTION. 01 PASS-VALUE PIC 9(6) VALUE ZERO. PROCEDURE DIVISION. MAIN. PERFORM UNTIL PASS-VALUE = 100 CALL “SUBPROG.EXE” USING BY REFERENCE PASS-VALUE DISPLAY PASS-VALUE AT 2020 CANCEL “SUBPROG.EXE” END-PERFORM. STOP RUN. Program name “SUBPROG.CBL”: $SET ANS85 IDENTIFICATION DIVISION. PROGRAM-ID. PASSENGER. DATA DIVISION. LINKAGE SECTION. 01 DUMMY-ONE PIC 9(6). PROCEDURE DIVISION USING DUMMY-ONE. ADD 1 TO DUMMY-ONE. END PROGRAM PASSENGER.

Additional reference words: 3.00 3.00a Copyright Microsoft Corporation 1993.