Microsoft KB Archive/57743

Passing a User-Defined Structure from FORTRAN to COBOL

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

3.00 3.00a MS-DOS

Summary: The two programs shown below demonstrate how a Microsoft FORTRAN program can pass a user-defined structure to COBOL. 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 FORTRAN, query on the following word: COB2FOR 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; FL /c /FPi /Lr FOR.FOR ; LINK /NOE /NOD FOR COB,,,LLIBFE LCOBOL ; Please note that the above FORTRAN library LLIBFE.LIB may be called LLIBFER.LIB, depending on how you installed FORTRAN. The following COBOL program is COB.CBL, which displays the elements of a user-defined structure passed from a calling FORTRAN program: $SET LITLINK IDENTIFICATION DIVISION. PROGRAM-ID. &quot;_CobProg“. DATA DIVISION. WORKING-STORAGE SECTION. LINKAGE 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 USING REC-1. DISPLAY”Passed INTNUM : &quot; INTNUM. DISPLAY “Passed LONGNUM :” LONGNUM. DISPLAY “Passed THESTRING :” THESTRING. STOP RUN. The following program is FOR.FOR, which initializes a user-defined structure that is then passed to a COBOL program: INTERFACE TO SUBROUTINE COBPROG [C] (FORREC) STRUCTURE /F_RECORD/ INTEGER2 I INTEGER4 J CHARACTER8 FSTRING END STRUCTURE RECORD /F_RECORD/ FORREC [REFERENCE] END STRUCTURE /F_RECORD/ INTEGER2 I INTEGER4 J CHARACTER8 FSTRING END STRUCTURE RECORD /F_RECORD/ FORREC FORREC.I = 123 FORREC.J = 98765 FORREC.FSTRING = ‘FORTRAN!’ CALL COBPROG(FORREC) END FOR.EXE produces the following output: Passed INTNUM : 00123 Passed LONGNUM : 000098765 Passed THESTRING : FORTRAN!

Copyright Microsoft Corporation 1990.