In Part II of this series we left off discussing the command definition source code for the CRTMIPGM command. We completed discussing the PARM and QUAL statement. Let us now develop some other concepts as we continue to go through the source code.
Before continuing, you may want to review the source code for the CRTMIPGM command. You may also want to review the CL and RPG source code provided in Part I, which constitutes the MI compiler preprocessor -- CRTMIPG0.CLP and CRTMIPG1.RPG).
Special parameter values
Looking back at the QUAL statements we were discussing at the end of Part II, specifically the second QUAL statement (which defines the library portion of the PGM parameter), you can see that one of its parameters is DFT. When the DFT parameter is specified, its value will be used as a default when the command is prompted or if the user does not specify a value for the library. To be consistent with all the other CRTxxxPGM commands, we use the value *CURLIB as the default.
The default value *CURLIB defined on the DFT parameter is not a valid OS/400-i5/OS object name, so we have to let the system know that this is a special value that should be tolerated if specified (or left unchanged) by the user. For this, we use the SPCVAL parameter. The SPCVAL parameter is a two-part parameter; the first part -- called the From value -- tells the system the special value that should be allowed, while the second part -- called the To replacement value -- defines the associated value that will be passed to the CPP.
Normally this second part is passed as -is to the CPP and no validity checking is done. However, it has one special value of its own, and that special value just happens to be the value *CURLIB, specified without quotation marks (very important). When you specify the value *CURLIB (without quotation marks) for this second part, the system will automatically pass the actual name of the user's current library when the command is executed, so the CPP does not have to retrieve it (very useful). If you want the actual value of *CURLIB passed to the CPP, specify *CURLIB in single quotes.
Note: You can specify multiple special values.
The last parameter on this QUAL statement is the PROMPT parameter. The prompt text for the second (and subsequent) QUAL statement in a group is automatically indented when the command is prompted, so there is no need to specify leading blanks on the prompt text Library.
The SRCFILE parameter
The second parameter defined in the command definition source code is the name of the source file that contains the source member you want compiled. Its structure is similar to the PGM parameter (i.e., it is a qualified parameter). The two main differences:
- The first qualifier (the source file name) has a default value (QMISRC), thus MIN(1) is not specified on the PARM statement. Note that default values cannot be specified for required parameters (i.e., MIN > 0).
- The To replacement value is not specified for the *LIBL special value (see the SPCVAL parameter on the second QUAL statement). When the To replacement value is not specified, the From value is passed to the CPP.
The SRCMBR and TEXT parameters
The CRTMIPGM command's third and fourth parameters, SRCMBR and TEXT, are simple parameters (i.e., not qualified parameters). Note that the special values for these parameters, if specified, get passed to the CPP as is, so the CPP must process the special values, replacing them with the appropriate value (see CL program CRTMIPGM0.CLP).
Unfortunately, there is no mechanism to have the system use the value of another parameter or qualifier as the To replacement value. For example, the default value for the SRCMBR parameter is *PGM, which when specified indicates that the user wants to use the same name for the source member name as they specified on the *PGM parameter. It would be nice if there were a mechanism that automatically took care of this, but unfortunately there is not. So, the CPP will have to check the incoming SRCMBR parameter for the value *PGM and change it manually to the value in the incoming PGM parameter.
We'll wrap up the discussion in the next, and last, installment of this series.
About the author: Ron Turull is editor of Inside Version 5. He has more than 20 years' experience programming for and managing AS/400-iSeries systems.
This was first published in September 2005