24
Tue, Dec
1 New Articles

The CL Corner: Need Some Help with That Command?

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

Provide help text for user commands.

 

This article is the seventh in a series related to creating user commands. The first five articles introduced how to define various command parameter features and then implement those features within the command's CL-based command processing program (CPP). Starting with the sixth article, "Providing Help Text for a User Command," we began looking at how to use the Generate Command Documentation (GENCMDDOC) command to provide a starting point for our help text. In this article, we will look at how to code User Interface Manager (UIM) text, which can be used to create and maintain our command help text.

 

Before changing the UIM text generated by the GENCMDDOC command, let's first see what we have to start with. Having generated the UIM source into member TRMLFTCHR of source file QPNLSRC in the previous article, use the following two commands to first create a panel group named TRMLFTCHR and then associate this panel group as the help panel group for the TRMLFTCHR command.

 

CRTPNLGRP PNLGRP(TRMLFTCHR)

 

CHGCMD CMD(TRMLFTCHR) HLPPNLGRP(*LIBL/TRMLFTCHR) HLPID(*CMD)

 

If you now prompt the TRMLFTCHR command and use F1 while the cursor is positioned on the prompt line containing the VAR parameter prompt, you will see the help text title "Value (VAR) – Help" followed by the help text:

 

Specifies <...>

 

This is a required parameter.

 

character-value

    Specify the <...>

 

If you use F1 while the cursor is positioned on the line above the VAR parameter prompt, you will see the default help text associated with the command, each parameter of the command, and examples for using the command. With this help text as our initial starting point, we will now enhance this default help with a description of what the TRMLFTCHR command really does when run.

 

Looking at member TRMLFTCHR of source file QPNLSRC with an editor such as SEU, you should find the first few lines of TRMLFTCHR being similar to the following:

 

:pnlgrp submsgf='VINING/USERMSGF'.                                    

.*********************************************************************

.*  Help for command TRMLFTCHR                                        

.*********************************************************************

:help name='TRMLFTCHR'.                                               

&msg(TRM0001). - Help                                                  

:p.The &msg(TRM0001). (TRMLFTCHR) command <...>                       

.* Describe the function provided by the command.                     

:p.:hp2.Restrictions::ehp2.                                           

:ul.                                                                   

:li.                                                                  

You must have <...>                                                   

.* List all special authorities required to run the command.          

:li.                                                                  

You must have <...>                                                   

.* List object or data authorities required to run the command.       

:li.                                                                   

This command is conditionally threadsafe, <...>                       

.* If conditionally threadsafe, list threadsafe conditions or restrictictions.

:li.                                                                   

<...>                                                                 

.* Describe other command-level restrictions.                         

.* Parameter-level restrictions belong in parameter help sections, not here.

:eul.                                                                  

:ehelp.

 

What you are seeing is UIM source defining the initial help text for the command TRMLFTCHR. UIM is a tag-based language, meaning that certain tags, or commands, are imbedded in the source to define various elements of the document. In our case, the document is the help text for the TRMLFTCHR command. The tags are surrounded by common start and stop characters. For UIM, the tag start character is a colon (:) and the end character is a period (.). Another tag-based language that you might be familiar with is HTML. In the case of HTML, the tag start character is the less-than symbol (<) and the end character is the greater-than symbol (>). Associated with each UIM tag can be zero, one, or more attributes.

 

The first source line, :pnlgrp submsgf='VINING/USERMSGF'., is a panel group (pnlgrp) tag with one attribute specified, submsgf='VINING/USERMSGF'. The pnlgrp tag defines the start of a panel group definition, and only one pnlgrp tag can be used in the source member. The associated epnlgrp tag defines the end of the panel group definition. The submsgf attribute allows you to specify the default message file to be used when the &msg symbol is encountered in the panel group definition. You might recall from the previous article that the &msg symbol can be used to substitute the first-level text of a message description, within the help text document, when the &msg symbol identifies a message ID. The value found in the generated source, VINING/USRMSGF, is based on the value specified for the Prompt file (PMTFILE) parameter when creating the TRMLFTCHR command with the CRTCMD command.

 

The next three lines, those starting with a period and an asterisk (.*), are comments generated by the GENCMDDOC command. The comment must start in columns 1 and 2 of the source record.

 

Having defined the start of the panel group and provided a comment concerning what the panel group represents (help for command TRMLFTCHR), we're now ready to provide the actual help text. The next tag, :help, does just that. The help tag identifies the start of a help module and, similar to the pnlgrp tag, requires an associated ehelp tag to indicate the end of the help module. For command help, there are usually several help modules within the panel group. There is generally one help module introducing the function of the command, one help module for each parameter of the command, a help module for examples of how to use the command, and a help module documenting the possible escape messages the command can send. The TRMLFTCHR help panel group will follow this convention.

 

The first help tag has the attribute "name=TRMLFTCHR" and represents the help module introducing the command. is used because we specified HLPID(*CMD) when we earlier used the CHGCMD command to associate the TRMLFTCHR panel group as the help panel group (HLPPNLGRP) for the command. HLPID(*CMD) tells the i command prompter that help modules are identified by the name of the command.

 

Following the help tag is a &msg symbol identifying message ID TRM0001 and then the text " – Help." This indicates that the first line of the help module should show the first-level message text for message TRM0001 (which is to be found in message file VINING/USERMSGF due to the previous pnlgrp submsgf specification) followed by a space, a dash, a space, and then the text 'HELP'. As a reminder, the first-level message text for TRM0001 is "Trim Left Characters," so the line displayed will be "Trim Left Characters – Help."

 

Following this is a :p tag. The p tag indicates that a new paragraph of text is to start. The paragraph text, as provided by the GENCMDDOC command, is simply "The &msg(TRM0001). (TRMLFTCHR) command <...>". One possible enhancement for this paragraph would be along the lines of the following:

 

:p.The &msg(TRM0001). (TRMLFTCHR) command changes the value of a CL   

character variable by trimming (removing) specified characters from the left of the specified CL variable. The result is returned left adjusted and blank padded.                                                             

 

I'll point out that the &msg symbol has now been used twice to reference the first-level text of message TRM0001. Frequently used text, such as the name of the command, should be stored in a message description. Storing common text in a message, and referring to this text with the &msg symbol, greatly simplifies the task of changing the help text if a wording change is ever needed.

 

A new paragraph is then started with another p tag. This paragraph though, rather than starting with text, starts with another tag. The tag is hp2 and indicates that the following phrase is to be highlighted. There are 10 variations of highlighting with the 2 indicating white on a color display, high intensity on a monochrome display, and bold on a printer. Following the tag is the phrase "Restrictions:" and then the tag ehp2. The ehp2 tag, as you can most likely guess, identifies the end of the highlighted phrase.

 

Following this is another new tag, ul. The ul tag identifies the start of an unordered list, where unordered means that each entry of the list is identified by a common character such as a bullet (lowercase o), a hyphen (-), or dashes (--). This is in contrast to an ordered list (tag ol), where each entry of the list is identified by sequential numbers or letters. Each individual entry of the list is identified with the li (list item) tag with the end of the list indicated by either the eul or eol tag, depending on the type of list (unordered or ordered). As you can see in the GENCMDDOC-generated source, comments are provided suggesting the types of restrictions you may want to list. For now, we'll just go with one list item in the list of restrictions, as shown below.

 

:p.:hp2.Restrictions::ehp2.                                           

:ul.                                                                  

:li.                                                                  

The TRMLFTCHR command is valid only in CL programs.                    

:eul.                                                                 

 

Though not shown, you can nest lists (unordered and ordered). As our list represents a first-level list, each list item will be preceded by a bullet.

 

At this point, we're done with our introduction to the TRMLFTHCR command, so we will end the help module with the ehlp tag. Here's the entire help module:

 

:help name='TRMLFTCHR'.                                               

&msg(TRM0001). - Help                                                  

:p.The &msg(TRM0001). (TRMLFTCHR) command changes the value of a CL   

character variable by trimming (removing) specified characters from the left of the specified CL variable. The result is returned left        

adjusted and blank padded.                                                             

:p.:hp2.Restrictions::ehp2.                                           

:ul.                                                                  

:li.                                                                   

The TRMLFTCHR command is valid only in CL programs.                   

:eul.                                                                 

:ehelp.                                                               

 

A few observations to point out about the TRMLFTCHR help module shown above. You might have noticed that the text for the paragraph starts on the same source line as the p tag while the text for the list item starts on the following source line. This is a matter of personal preference. The text associated with the paragraph could just as well have started on the source line following the tag, and the text for the list item on the same source line as the tag. Blank spaces between the tag and the text are removed when creating, or compiling, the panel group. Along the same lines, each line of text within a paragraph will have trailing blanks trimmed to one blank, allowing, for instance, each source line of our introductory paragraph to end on an arbitrary word boundary. These observations on the text formatting performed by UIM are just a few examples of how UIM help can simplify your creation of textual material. You provide the text; UIM provides the consistent display of the text. Those of you who have created textual material in the past using DDS might appreciate this difference, along with the absence of explicit source continuation characters from line to line!

 

The next set of help modules are related to the individual keyword parameters defined by the TRMLFTCHR command. We will look at these modules, and the new tags and features they introduce, next month. In the meantime, if you just can't wait to dig into the next help module, you can find much of the UIM reference material in Appendix A: UIM Panel Group Definition Language of the Application Display Programming manual, which is located here.

 

If you would like to see what you've done so far, recreate the TRMLFTCHR panel group with this command:

 

CRTPNLGRP PNLGRP(TRMLFTCHR)

 

Then prompt the command, press F1 to access the help text associated with the VAR parameter (which we haven't changed yet), and then press F2 for extended help.

More CL Questions?

Wondering how to accomplish a function in CL? Send your CL-related questions to me at This email address is being protected from spambots. You need JavaScript enabled to view it.. I'll try to answer your burning questions in future columns.

 

BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  • SB Profound WC 5536 Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application. You can find Part 1 here. In Part 2 of our free Node.js Webinar Series, Brian May teaches you the different tooling options available for writing code, debugging, and using Git for version control. Brian will briefly discuss the different tools available, and demonstrate his preferred setup for Node development on IBM i or any platform. Attend this webinar to learn:

  • SB Profound WP 5539More than ever, there is a demand for IT to deliver innovation. Your IBM i has been an essential part of your business operations for years. However, your organization may struggle to maintain the current system and implement new projects. The thousands of customers we've worked with and surveyed state that expectations regarding the digital footprint and vision of the company are not aligned with the current IT environment.

  • SB HelpSystems ROBOT Generic IBM announced the E1080 servers using the latest Power10 processor in September 2021. The most powerful processor from IBM to date, Power10 is designed to handle the demands of doing business in today’s high-tech atmosphere, including running cloud applications, supporting big data, and managing AI workloads. But what does Power10 mean for your data center? In this recorded webinar, IBMers Dan Sundt and Dylan Boday join IBM Power Champion Tom Huntington for a discussion on why Power10 technology is the right strategic investment if you run IBM i, AIX, or Linux. In this action-packed hour, Tom will share trends from the IBM i and AIX user communities while Dan and Dylan dive into the tech specs for key hardware, including:

  • Magic MarkTRY the one package that solves all your document design and printing challenges on all your platforms. Produce bar code labels, electronic forms, ad hoc reports, and RFID tags – without programming! MarkMagic is the only document design and print solution that combines report writing, WYSIWYG label and forms design, and conditional printing in one integrated product. Make sure your data survives when catastrophe hits. Request your trial now!  Request Now.

  • SB HelpSystems ROBOT GenericForms of ransomware has been around for over 30 years, and with more and more organizations suffering attacks each year, it continues to endure. What has made ransomware such a durable threat and what is the best way to combat it? In order to prevent ransomware, organizations must first understand how it works.

  • SB HelpSystems ROBOT GenericIT security is a top priority for businesses around the world, but most IBM i pros don’t know where to begin—and most cybersecurity experts don’t know IBM i. In this session, Robin Tatam explores the business impact of lax IBM i security, the top vulnerabilities putting IBM i at risk, and the steps you can take to protect your organization. If you’re looking to avoid unexpected downtime or corrupted data, you don’t want to miss this session.

  • SB HelpSystems ROBOT GenericCan you trust all of your users all of the time? A typical end user receives 16 malicious emails each month, but only 17 percent of these phishing campaigns are reported to IT. Once an attack is underway, most organizations won’t discover the breach until six months later. A staggering amount of damage can occur in that time. Despite these risks, 93 percent of organizations are leaving their IBM i systems vulnerable to cybercrime. In this on-demand webinar, IBM i security experts Robin Tatam and Sandi Moore will reveal:

  • FORTRA Disaster protection is vital to every business. Yet, it often consists of patched together procedures that are prone to error. From automatic backups to data encryption to media management, Robot automates the routine (yet often complex) tasks of iSeries backup and recovery, saving you time and money and making the process safer and more reliable. Automate your backups with the Robot Backup and Recovery Solution. Key features include:

  • FORTRAManaging messages on your IBM i can be more than a full-time job if you have to do it manually. Messages need a response and resources must be monitored—often over multiple systems and across platforms. How can you be sure you won’t miss important system events? Automate your message center with the Robot Message Management Solution. Key features include:

  • FORTRAThe thought of printing, distributing, and storing iSeries reports manually may reduce you to tears. Paper and labor costs associated with report generation can spiral out of control. Mountains of paper threaten to swamp your files. Robot automates report bursting, distribution, bundling, and archiving, and offers secure, selective online report viewing. Manage your reports with the Robot Report Management Solution. Key features include:

  • FORTRAFor over 30 years, Robot has been a leader in systems management for IBM i. With batch job creation and scheduling at its core, the Robot Job Scheduling Solution reduces the opportunity for human error and helps you maintain service levels, automating even the biggest, most complex runbooks. Manage your job schedule with the Robot Job Scheduling Solution. Key features include:

  • 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.

  • LANSAWhen it comes to creating your business applications, there are hundreds of coding platforms and programming languages to choose from. These options range from very complex traditional programming languages to Low-Code platforms where sometimes no traditional coding experience is needed. Download our whitepaper, The Power of Writing Code in a Low-Code Solution, and:

  • LANSASupply Chain is becoming increasingly complex and unpredictable. From raw materials for manufacturing to food supply chains, the journey from source to production to delivery to consumers is marred with inefficiencies, manual processes, shortages, recalls, counterfeits, and scandals. In this webinar, we discuss how:

  • 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

  • Profound Logic Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application.

  • 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: