• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • Prompt Control Controls Parsimonious Command Prompting

    February 22, 2012 Ted Holt

    Note: The code accompanying this article is available for download here.

    I like everything to be as simple as possible. Call me parsimonious, but I agree with my friend Cletus the Codeslinger, who says, “When something’s complicated, somebody’s trying to get your money.” One way to simplify CL command prompting is to show relevant parameters only. Here’s how that’s done.

    By default, prompting a CL command shows all parameters, even though some of them may not be applicable to what the user is trying to accomplish. The Prompt Control Definition (PMTCTL) keyword allows you to prompt for a parameter only if the user needs to supply a value. Rather than overwhelm the user with many parameter entry fields, some of which do not apply, you show parameters only if they need a value.

    Consider IBM‘s ANZOBJCVN (Analyze Object Conversion) command, which helps prepare V5R4 systems for a later version of the operating system. If you type the command name and press F4, you’ll see the display shown in Figure 1.

    Figure 1.

    The system wants to know if you’re going to collect data or print a report. If you enter *COLLECT, you’ll see the display in Figure 2.

    Figure 2.

    But if you enter *REPORT, you’ll see the display in Figure 3. Notice the difference in the parameters in Figures 2 and 3. The value of the OPTION parameter determines whether or not other parameters apply.

    Figure 3.

    PMTCTL lets you specify a condition (or conditions) that must apply in order for a parameter to be prompted. Here’s an example:

    IFCOLLECT:  PMTCTL     CTL(OPTION) COND((*EQ *COLLECT))
    

    The condition has a name, IFCOLLECT, which is specified as the label. Condition IFCOLLECT is true if the OPTION parameter is equal to *COLLECT. Any parameter that is controlled by this keyword will be shown in the prompt list only when this condition is true. Here’s how to make the LIB parameter appear in the prompt when IFCOLLECT is true.

    PARM  KWD(LIB) ... PMTCTL(IFCOLLECT) ...
    

    Here’s a more complete example, using a command I call DOIT:

                 CMD        PROMPT('Do it')
    
                 PARM       KWD(OPTION) TYPE(*CHAR) LEN(8) RSTD(*YES) +
                              VALUES(*COLLECT *REPORT) MIN(1) +
                              EXPR(*YES) PROMPT('Option')
    
                 PARM       KWD(LIB) TYPE(*GENERIC) SPCVAL((*ALLUSR) +
                              (*NONE)) EXPR(*YES) PMTCTL(IFCOLLECT) +
                              PROMPT('Libraries to analyze')
    
                 PARM       KWD(RPTTYPE) TYPE(*CHAR) LEN(7) RSTD(*YES) +
                              SPCVAL((*CVNPRB) (*LIBSUM) (*LIBDTL) +
                              (*OBJSUM) (*OBJDTL)) +
                              SNGVAL((*ALLAVL)) +
                              MIN(0) MAX(5) PMTCTL(IFREPORT) +
                              PROMPT('Type of report')
    
     IFCOLLECT:  PMTCTL     CTL(OPTION) COND((*EQ *COLLECT))
     IFREPORT:   PMTCTL     CTL(OPTION) COND((*EQ *REPORT))
    

    Notice the two PMTCTL statements at the bottom. You don’t have to put them at the end of the command source member, but that’s where I like to put them. IFCOLLECT and IFREPORT are both controlled by the OPTION parameter. LIB will be prompted only when IFCOLLECT is true, and RPTTYPE will only be prompted when IFREPORT is true.

    The example I’ve given is simple. You can create more complex conditions by using multiple values on the COND keyword, and by using the NBRTRUE and LGLREL keywords. I’ll let you read about those on your own time. I’ve found that the simple conditions like those in my illustration are almost always sufficient.



                         Post this story to del.icio.us
                   Post this story to Digg
        Post this story to Slashdot

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Tags:

    Sponsored by
    Maxava

    Migrate IBM i with Confidence

    Tired of costly and risky migrations? Maxava Migrate Live minimizes disruption with seamless transitions. Upgrading to Power10 or cloud hosted system, Maxava has you covered!

    Learn More

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Sponsored Links

    Infor:  On-Demand Webcast: Top Business Drivers Impacting ERP Strategies for Distributors
    System i Developer:  Upgrade your skills at the RPG & DB2 Summit in Fort Worth, March 26-28
    ProData Computer Services:  Share real time data across platforms with RDB Connect

    IT Jungle Store Top Book Picks

    BACK IN STOCK: Easy Steps to Internet Programming for System i: List Price, $49.95

    The iSeries Express Web Implementer's Guide: List Price, $49.95
    The iSeries Pocket Database Guide: List Price, $59
    The iSeries Pocket SQL Guide: List Price, $59
    The iSeries Pocket WebFacing Primer: List Price, $39
    Migrating to WebSphere Express for iSeries: List Price, $49
    Getting Started with WebSphere Express for iSeries: List Price, $49
    The All-Everything Operating System: List Price, $35
    The Best Joomla! Tutorial Ever!: List Price, $19.95

    RPG & DB2 Summit Picks Tipton for Keynote The Application RISC Machine System/500

    Leave a Reply Cancel reply

Volume 12, Number 4 -- February 22, 2012
THIS ISSUE SPONSORED BY:

WorksRight Software
Infor
inFORM Decisions

Table of Contents

  • bsearch: Partial Key Searches and More
  • Prompt Control Controls Parsimonious Command Prompting
  • Why Can’t I Access My Remote System’s AS/400 IFS?

Content archive

  • The Four Hundred
  • Four Hundred Stuff
  • Four Hundred Guru

Recent Posts

  • Meet The Next Gen Of IBMers Helping To Build IBM i
  • Looks Like IBM Is Building A Linux-Like PASE For IBM i After All
  • Will Independent IBM i Clouds Survive PowerVS?
  • Now, IBM Is Jacking Up Hardware Maintenance Prices
  • IBM i PTF Guide, Volume 27, Number 24
  • Big Blue Raises IBM i License Transfer Fees, Other Prices
  • Keep The IBM i Youth Movement Going With More Training, Better Tools
  • Remain Begins Migrating DevOps Tools To VS Code
  • IBM Readies LTO-10 Tape Drives And Libraries
  • IBM i PTF Guide, Volume 27, Number 23

Subscribe

To get news from IT Jungle sent to your inbox every week, subscribe to our newsletter.

Pages

  • About Us
  • Contact
  • Contributors
  • Four Hundred Monitor
  • IBM i PTF Guide
  • Media Kit
  • Subscribe

Search

Copyright © 2025 IT Jungle