ILE COBOL Programmer's Guide

Sample Code for ILE C Procedure Call Example 1

Example 1 has two code samples:

C1 QCSRC
An ILE C procedure that is bound to the ILE COBOL program.

CBL1 QCBLLESRC
An ILE COBOL procedure that calls the bound ILE C procedure.

The sample code for C1 QCSRC is shown in Figure 70.

Figure 70. Source code for C1 QCSRC



/* C1 QCSRC --- ILE C Procedure */
#include <stdio.h>
#include <stdlib.h>
void C1(char *result)
{
*(result+9) = '*';
*(result+10) = '#';
return;
}

The sample code for CBL1 QCBLLESRC is shown in Figure 71.

Figure 71. Source code for CBL1 QCBLLESRC


      *********************************************************************
      * cbl1 qcbllesrc
      *
      * Description:
      *
      *   COBOL source with ILE C procedure call.
      *
      *********************************************************************
       Identification Division.
        Program-Id.    cbl1.
        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 PROCEDURE "C1" USING 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 ]