ILE C/C++ Programmer's Guide

Source Code Pass Terminal Session Input to an ILE Program

CL program T1520CL1 is shown in Figure 51. It passes required parameters to the ILE C program T1520PG1.

Figure 54. T1520CL1 -- CL Source to Pass Variables to an ILE C Program


          PGM        PARM(&ITEMIN &PRICE &QUANTITY)(1)
              DCL        VAR(&USER)      TYPE(*CHAR) LEN(10)
              DCL        VAR(&ITEMIN)    TYPE(*CHAR) LEN(20)
              DCL        VAR(&ITEMOUT)   TYPE(*CHAR) LEN(21)
              DCL        VAR(&PRICE)     TYPE(*DEC)  LEN(10 2)
              DCL        VAR(&QUANTITY)  TYPE(*DEC)  LEN(2 0)
              DCL        VAR(&NULL)      TYPE(*CHAR) LEN(1) VALUE(X'00')
              /* ADD NULL TERMINATOR FOR THE ILE C PROGRAM             */(2)
              CHGVAR     VAR(&ITEMOUT) VALUE(&ITEMIN *TCAT &NULL)
              /* GET THE USERID FOR THE AUDIT TRAIL                        */(3)
              RTVJOBA    USER(&USER)
              /* ENSURE AUDIT RECORDS WRITTEN TO CORRECT AUDIT FILE MEMBER */
              OVRDBF     FILE(T1520DD1) TOFILE(*LIBL/T1520DD1) +
                         MBR(T1520DD1) OVRSCOPE(*CALLLVL) SHARE(*NO)
              CALL       PGM(T1520PG1) PARM(&ITEMOUT &PRICE &QUANTITY +
                            &USER)
              DLTOVR     FILE(*ALL)
          ENDPGM

Notes:

  1. This program passes (by reference) the CL variables for item name, price, quantity, and user ID to an ILE C program T1520PG1. Variables in a CL program are passed by reference to allow an ILE C program to change the contents in the CL program.

  2. The variable ITEMOUT is null-terminated in the CL program T1520CL1. Passing CL variables passed from CL to ILE C are not automatically null-terminated on a compiled CL call. See Chapter 23, Using ILE C/C++ Call Conventions for information about null-terminated strings for compiled CL calls and command line CL calls.

  3. The Retrieve Job Attributes (RTVJOBA) command obtains the user ID for the audit trail.


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