• 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
    Raz-Lee Security

    With COVID-19 wreaking havoc, cybercriminals are taking advantage of the global impact that it has had on our families, our businesses and our societies. It is more important now than ever to ensure that IT systems are protected, so that when all of this is behind us, we can get back to business as usual as quickly as possible.

    iSecurity Anti-Ransomware protects organizations against ransomware attacks and other kinds of malware that may access and change business-critical data on your IBM i. It even protects against zero-day attacks. Anti-Viruses can only report on the damage an attack has caused, but not stop it.

    iSecurity Anti-Ransomware has been recently enhanced with a Self-Test feature that allows you to simulate a ransomware attack on your IBM i. The simulated attack is limited to the test folder and cannot harm any other folders or files. This new feature lets organizations see how they are protected against known or unknown ransomware.

    Key Features:

    • Real-time scanning for known and unknown ransomware threats.
    • Blocks and disconnects the intruder.
    • Instantaneously sends alerts to SIEM as well as the offending computer.
    • Self-Test for attack simulation
    • Classification of the attack based on log.
    • Automatic updates with the most current ransomware definitions.

    Contact us at https://www.razlee.com/anti-ransomware

    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

  • POWERUp Brings IBM i Base Back Together in the Big Easy
  • New Nav for i Brings New Stuff to You
  • Why Infor’s IDF Is Important for Customer Innovation
  • Four Hundred Monitor, May 25
  • IBM i PTF Guide, Volume 24, Number 21
  • How Committed Is Big Blue To The IBM Cloud?
  • Immutable Copies Are Only As Good As Your Validation
  • Guru: IBM i *USRPRF Security
  • ERP Transitions Loom for SAP on IBM i Customers
  • Inflation Pumps Up Global IT Spending, Supply Chain Deflates It

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 © 2022 IT Jungle

loading Cancel
Post was not sent - check your email addresses!
Email check failed, please try again
Sorry, your blog cannot share posts by email.