Using CLCRTPG to Create an MI Program
Assume that the source is in a member named MI01 in the source file MISRC,
which is created with a default record length (RCDLEN) of 92. The following
CLCRTPG CL program can be used to create an MI program called MI01. (An MI
program to call the Create Program (QPRCRTPG) API is developed in “Creating an
MI Version of CLCRTPG” on page 7-11.)
Note: All non-MI source examples are provided in CL, because CL is the one lan-
guage (other than REXX) that is standard on all AS/400 systems. Other
high-level languages (HLLs) could be used in place of the CL programs
(and in many cases would have been easier).
The following program reads a source file member into a program variable
(&MIPGMSRC) and then does a CALL to the QPRCRTPG API. This program has
many limitations (the major limitation is a program variable-size limit of 2000 bytes
for the source), but provides for a reasonably simple MI program creation scenario:
/\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\/
/\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\/
/\ \/
/\ Program Name: CLCRTPG \/
/\ \/
/\ Programming Language: CL \/
/\ \/
/\ Description: Create an MI program using the QPRCRTPG API. \/
/\ \/
/\ \/
/\ Header Files Included: None \/
/\ \/
/\ \/
/\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\/
PGM PARM(&SRCMBR)
DCLF FILE(MISRC)
DCL VAR(&SRCMBR) TYPE(\CHAR) LEN(1ð)
DCL VAR(&MIPGMSRC) TYPE(\CHAR) LEN(2ððð)
DCL VAR(&MIPGMSRCSZ) TYPE(\CHAR) LEN(4)
DCL VAR(&OFFSET) TYPE(\DEC) LEN(5 ð) VALUE(1)
DCL VAR(&PGMNAM) TYPE(\CHAR) LEN(2ð) +
VALUE(' \CURLIB ')
DCL VAR(&PGMTXT) TYPE(\CHAR) LEN(5ð) +
VALUE('Compare two packed arguments and +
return larger')
DCL VAR(&PGMSRCF) TYPE(\CHAR) LEN(2ð) +
VALUE('\NONE')
DCL VAR(&PGMSRCM) TYPE(\CHAR) LEN(1ð) VALUE(' ')
DCL VAR(&PGMSRCCHG) TYPE(\CHAR) LEN(13) VALUE(' ')
DCL VAR(&PRTFNAM) TYPE(\CHAR) LEN(2ð) +
VALUE('QSYSPRT \LIBL ')
DCL VAR(&PRTSTRPAG) TYPE(\CHAR) LEN(4) +
VALUE(X'ððððððð1')
DCL VAR(&PGMPUBAUT) TYPE(\CHAR) LEN(1ð) +
VALUE('\ALL ')
DCL VAR(&PGMOPTS) TYPE(\CHAR) LEN(22) +
VALUE('\LIST \REPLACE ')
DCL VAR(&NUMOPTS) TYPE(\CHAR) LEN(4) +
VALUE(X'ððððððð2')
LOOP: RCVF
Chapter 7. Machine Interface Programming 7-5