When using CL programs there is often a need to supply input to a CL command within the program. This is often accomplished by using a display prompt, see "Prompting Within CL Programs," DataNetwork (now Midrange Computing), April 1989, or by passing parameters to the program. You can have the system prompt a system-supplied CL command or a user-defined command by placing a ? before the CL command. For example, ?DLTF will prompt the DLTF command.
But this only scratches the surface of what you can do. You can assign values to parameters and them prompt the command using a ?. The values you assigned cannot be changed by the user. This example will prompt the command INZTAP and not allow the user to change the DENSITY parameter value:
PGM . ?INZTAP DENSITY(3200) . ENDPGM
If you choose, you can supply a command with default parameters and allow the user to either accept the defaults or supply their own values. You can also select which parameters you want to prompt. IBM calls this selective prompting. In the following example, only the three defined parameters are displayed:
PGM . OVRPRTF ??FILE(REPORT) + ?*TOFILE(QPRINT) + ??COPIES(3) . ENDPGM
A double question mark (??) indicates the parameter can be changed, while a single question mark followed by an asterisk (?*) does not allow modification. In the example above, the operator can change the default values on the FILE and COPIES parameters, but not the TOFILE parameter. If the operator presses F3 or F12 while a command is prompted, they will receive an escape message (CPF6801), which could be monitored.
We use this technique in menus. A user-defined command is prompted using a ?. The operator enters the necessary values for the selected parameters. The parameters are then passed to an RPG program.
A question mark followed by a hyphen (?-) allows selective display omissions. A question mark followed by the less than character (?<) is used for IBM-supplied commands. It causes a parameter to be displayed and is input-capable, but the command default is sent to the CPP unless the value displayed is changed.
As with most things in programming, there are some restrictions when prompting. For an in-depth discussion, check out the Control Language Programmer's Guide (SC21-8077) for the restrictions and the valid selective prompting characters.
Blake Messenbrink Jonesboro, Arkansas