• 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
    VISUAL LANSA 16 WEBINAR

    Trying to balance stability and agility in your IBM i environment?

    Join this webinar and explore Visual LANSA 16 – our enhanced professional low-code platform designed to help organizations running on IBM i evolve seamlessly for what’s next.

    🎙️VISUAL LANSA 16 WEBINAR

    Break Monolithic IBM i Applications and Unlock New Value

    Explore modernization without rewriting. Decouple monolithic applications and extend their value through integration with modern services, web frameworks, and cloud technologies.

    🗓️ July 10, 2025

    ⏰ 9 AM – 10 AM CDT (4 PM to 5 PM CEST)

    See the webinar schedule in your time zone

    Register to join the webinar now

    What to Expect

    • Get to know Visual LANSA 16, its core features, latest enhancements, and use cases
    • Understand how you can transition to a MACH-aligned architecture to enable faster innovation
    • Discover native REST APIs, WebView2 support, cloud-ready Azure licensing, and more to help transform and scale your IBM i applications

    Read more about V16 here.

    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

  • With Power11, Power Systems “Go To Eleven”
  • With Subscription Price, IBM i P20 And P30 Tiers Get Bigger Bundles
  • Izzi Buys CNX, Eyes Valence Port To System Z
  • IBM i Shops “Attacking” Security Concerns, Study Shows
  • IBM i PTF Guide, Volume 27, Number 26
  • Liam Allan Shares What’s Coming Next With Code For IBM i
  • From Stable To Scalable: Visual LANSA 16 Powers IBM i Growth – Launching July 8
  • VS Code Will Be The Heart Of The Modern IBM i Platform
  • The AS/400: A 37-Year-Old Dog That Loves To Learn New Tricks
  • IBM i PTF Guide, Volume 27, Number 25

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