TechTalk: Prompting in CL

CL
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

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

BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  •  

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: