Tips and Techinques: Create a Command Parameter That Accepts Commands

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

Years ago, only IBM could create commands that accepted other commands as parameters. For example, the IF command in CL allows you to put another CL command on the THEN parameter. Not only does this capability allow you to specify a CL command, it also allows you to do what's called second-level prompting.

IBM added a special data type for parameters that supports CL commands and second-level prompting. The data type is *CMDSTR, and it's used in this week's featured command, SAVOBJIFS. (See "Back Up to the IFS.")

Here is the specific command definition statement for the SAVCMD parameter:



  PARM       KWD(SAVCMD) TYPE(*CMDSTR) LEN(2048) MIN(1) +
               PROMPT('SAVxxx command to run')

For the most part, this statement looks just like any other command definition statement, but the data type is *CMDSTR. The *CMDSTR parameter type allows the user to type in any valid CL command. The command is not run by the parameter; instead, it is simply passed as a character string parameter to the command's command processing program. But the system does allow the user to enter the command and prompt the command, and it automatically syntax checks the command.

Previously, there was a command definition parameter type of *CMD. Many people, including yours truly, attempted to create commands using this parameter--but alas, this was reserved for IBM-only commands. I believe it was used when IBM created the IF, ELSE, and MONMSG commands.

A few years ago, IBM began abandoning CL commands in favor of the GUI interface in Client Access. Fortunately, they have since repented and now continue to create new commands and support the CL language itself.

As you create your own CL commands, remember the *CMDSTR parameter type so that when a design calls for a CL command, you'll have the tools to make it happen.

Bob Cozzi is a programmer/consultant, writer/author, and software developer. His popular RPG xTools add-on subprocedure library for RPG IV is fast becoming a standard with RPG developers. His book The Modern RPG Language has been the most widely used RPG programming book for more than a decade. He, along with others, speaks at and produces the highly popular RPG World conference for RPG programmers.

BOB COZZI

Bob Cozzi is a programmer/consultant, writer/author, and software developer. His popular RPG xTools add-on subprocedure library for RPG IV is fast becoming a standard with RPG developers. His book The Modern RPG Language has been the most widely used RPG programming book for more than a decade. He, along with others, speaks at and produces the highly popular RPG World conference for RPG programmers.


MC Press books written by Robert Cozzi available now on the MC Press Bookstore.

RPG TnT RPG TnT
Get this jam-packed resource of quick, easy-to-implement RPG tips!
List Price $65.00

Now On Sale

The Modern RPG IV Language The Modern RPG IV Language
Cozzi on everything RPG! What more could you want?
List Price $99.95

Now On Sale

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: