ILE COBOL Programmer's Guide

Sample Code for ILE C Program Call Example

The example has two code samples:

C2 QCSRC
An ILE C program.

CBL2 QCBLLESRC
An ILE COBOL program with an ILE C program call.

The sample code for C2 QCSRC is shown in Figure 74.

Figure 74. Source code for C2 QCSRC



/* C2 QCSRC --- ILE C Program */
#include <stdio.h>
#include <stdlib.h>
void main(int argc, char *argv[])
{
*(argv[1]+9) = '*';
*(argv[1]+10) = '#';
return;
}

The sample code for CBL2 QCBLLESRC is shown in Figure 75.

Figure 75. Source code for CBL2 QCBLLESRC


      *********************************************************************
      * cbl2 qcbllesrc
      *
      * Description:
      *
      *   COBOL source with ILE C program call.
      *
      *********************************************************************
       Identification Division.
        Program-Id.    cbl2.
        Author.        Author's Name.
        Installation.  IBM Toronto Lab
        Date-Written.  July 14, 1998.
        Date-Compiled. Will be replaced by compile date.
       Environment Division.
        Configuration Section.
         Source-Computer.   IBM-ISERIES.
         Object-Computer.   IBM-ISERIES.
         Special-Names.
       INPUT-OUTPUT SECTION.
 
       File-Control.
       Data Division.
        Working-Storage Section.
         01  RESULT-STRING    PIC X(20)       VALUE ALL "X".
 
       Procedure Division.
 
       TEST1-INIT.
           DISPLAY RESULT-STRING.
           CALL "C2" USING BY REFERENCE RESULT-STRING.
           DISPLAY RESULT-STRING.
           STOP run.
      *----------------------------------------------------------------------
      * Output before call
      * XXXXXXXXXXXXXXXXXXXX
      * Output after call
      * XXXXXXXXX*#XXXXXXXXX 


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]