Microsoft KB Archive/57746

Passing a Record Structure from COBOL to Pascal by Reference

PSS ID Number: Q57746 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 a user-defined record 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; The following COBOL program is COB.CBL, which calls a Pascal procedure and passes a user-defined record. After returning from the Pascal procedure, all the values in the record are displayed. $SET LITLINK IDENTIFICATION DIVISION. DATA DIVISION. WORKING-STORAGE SECTION. 01 REC-1. 05 INTNUM PIC 9(4) COMP-5. 05 LONGNUM PIC 9(8) COMP-5. 05 THESTRING PIC X(8). PROCEDURE DIVISION. CALL “P_PProg” USING REC-1. DISPLAY “Returned INTNUM :” INTNUM. DISPLAY “Returned LONGNUM :” LONGNUM. DISPLAY “Returned THESTRING :” THESTRING. STOP RUN. The following program is P.PAS, which assigns values to the passed record structure: module pproc; TYPE TheRec = RECORD i : integer; j : integer4; TheString : STRING(8); END; procedure PProg(VARS PasRec : TheRec); begin PasRec.i := 206; PasRec.j := 98765; PasRec.TheString := ‘Pascal’; end; end. COB.EXE produces the following output: Returned INTNUM : 00206 Returned LONGNUM : 000098765 Returned THESTRING : Pascal

Copyright Microsoft Corporation 1990.