Microsoft KB Archive/57439

From BetaArchive Wiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Passing Common Numeric Types from COBOL to Pascal by Reference

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

3.00 3.00a MS-DOS

Summary: The two programs shown below demonstrate how a Microsoft COBOL program can pass common numeric data types to Pascal. This information about interlanguage calling 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

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 above Pascal library LIBPASE.LIB might 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 value. After returning from the Pascal procedure, both values are displayed. $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. DISPLAY “Returned PIC 9(4):” FIELD1. DISPLAY “Returned PIC 9(8):” FIELD2. STOP RUN. The following program is P.PAS, which assigns values to the passed parameters: module pproc; procedure PProg(vars i : integer; vars j : integer4); begin i := 206; j := 98765; end; end. COB.EXE produces the following output: Returned PIC 9(4): 00206 Returned PIC 9(8): 000098765

Copyright Microsoft Corporation 1990.