ILE C/C++ Programmer's Guide


Creating a Program in One Step

You can use the CRTBNDC and CRTBNDCPP Create Bound Program commands to create a program (*PGM object) in one step.

The Create Bound Program commands combine the steps of compiling and binding. Using them is the same as first calling the CRTCMOD or CRTCPPMOD Create Module command, then calling the Create Program (CRTPGM) command, except that the module created by the Create Module command step is deleted after the CRTPGM step.

To use the Create Bound Program commands, the source member must contain a main() function.

Note:
When a CRTPGM parameter does not appear in the Create Bound Program command, the CRTPGM parameter default is used. For example, the parameter ACTGRP(*NEW) is the default for the CRTPGM command, and is used for the Create Bound Program command. You can change the CRTPGM parameter defaults by using the Change Command Defaults (CHGCMDDFT) command.

You can use the CRTSQLCI or CRTSQLCPPI command to start the ILE C compiler and create a program object. The SQL database can be accessed from an ILE C/C++ program if you embed SQL statements in the ILE C/C++ source.

Example:

  1. To create the program T1520ALP, using the source found in Figure 2, enter:

    CRTBNDC PGM(MYLIB/T1520ALP) SRCFILE(QCPPLE/QACSRC)
    TEXT('Adds integers and prints characters') OUTPUT(*PRINT)
    OPTION(*SHOWINC *NOLOGMSG) FLAG(30) MSGLMT(10) 
    CHECKOUT(*PARM) DBGVIEW(*ALL)

    The options specified are:

  2. To see the compiler listing, enter one of the following CL commands:

    Select an option to see the compiler listing.

  3. To run the program enter:

    CALL PGM(MYLIB/T1520ALP)
  4. Type a and press Enter. Type 9 and press Enter. Type b and press Enter. Type 8 and press Enter. Type + and press Enter.

    The interactive session is as shown:

    +--------------------------------------------------------------------------------+
    |  > a                                                                           |
    |  > 9                                                                           |
    |  > b                                                                           |
    |  > 8                                                                           |
    |  > +                                                                           |
    |    Characters are ab                                                           |
    |    Sum of Digits is 17                                                         |
    |    Press ENTER to end terminal session.                                        |
    +--------------------------------------------------------------------------------+


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