Microsoft KB Archive/57440

From BetaArchive Wiki

“? Error: No Room in Heap” When Pascal Called from COBOL

PSS ID Number: Q57440 Article last modified on 12-06-1990

3.00 3.00a MS-DOS

Summary: When a Microsoft COBOL version 3.00 program is LINKed with a Pascal routine, an “out of heap space” error message can occur at run time. This error commonly occurs if screen input or output is performed in the Pascal routine. This can be worked around by making the Pascal routine the main program, which then calls COBOL. The COBOL program can then call the Pascal routines that it needs. This information applies to Microsoft COBOL versions 3.00 and 3.00a for MS-DOS.

More Information: For more examples of passing other types of parameters between COBOL and Pascal, query on the following word: COB2PAS For a complete discussion about mixed-language programming with COBOL, search in the Software/Data Library for the following word: COBMIXED

Code Example

The following two programs demonstrate the “out of heap space” error. To demonstrate these programs from an .EXE program, compile and link as follows: COBOL COB.CBL; PAS1 P.PAS ; PAS2 LINK /NOE COB MINITP P,,,LCOBOL LIBPASE; Please note that the Pascal library above LIBPASE.LIB may be called LIBPASER.LIB, depending on how you installed Pascal. The following COBOL program is COB.CBL, which calls a Pascal procedure and passes an integer and a long integer by reference: $SET LITLINK IDENTIFICATION DIVISION. DATA DIVISION. WORKING-STORAGE SECTION. 01 FIELD1 PIC 9(4) COMP-5 VALUE 123. 01 FIELD2 PIC 9(8) COMP-5 VALUE 123456. PROCEDURE DIVISION. CALL “P_PProg” USING FIELD1, FIELD2. STOP RUN. The following program is P.PAS, which displays the passed values: module pproc; procedure PProg(vars i : integer; vars j : integer4); begin writeln(i, j); end; end. COB.EXE produces the following output: ? Error: no room in heap Error Code 2001 PC = 2369: 2050; SS = 29EA, FP = 2996, SP = 2ECE

Copyright Microsoft Corporation 1990.