Keeping up With RDi Enhancements
RDi enhancements arrive frequently and usually are not timed with the announcements that get a lot of attention, like new releases or TRs for IBM i, RPG, etc. It can be hard to keep up. This month we thought we'd try to help out by highlighting some of our favorite recent RDi enhancements—just in case you may have missed them. In this review, we're looking at changes made in V9.5.1 (from September 2016) and V184.108.40.206 (from December 2016).
We previously wrote about our most favorite of these enhancements: native support to run RDi on our Macs without a Windows VM. That was something we had been awaiting for a very long time. We won't go into that again here, but there were other goodies that came with V9.5.1 that may excite non-Mac RDi users even more.
The same easy commenting capability that we've enjoyed when coding in RPG or COBOL has now been added for CL and DDS. This is particularly helpful for CL where the comment style requires something at the beginning and end of each line, which makes commenting much more cumbersome.
In case you are not already familiar with the existing RDi commenting support, here are the basics. If you only want to comment out one line of code, simply position your cursor on the line and use the keyboard shortcut Ctrl + / (or if you're on a Mac, it's command + /). To comment out a block of code, select the block of code using your favorite method (we prefer Alt-L on the first and last lines of the block) and use the same shortcut. To un-comment a line or block of lines, use Ctrl + \ (command + \ on Mac). That's a lot easier than trying to do it in SEU, isn't it?
RPG Outline Improvements
Since we already consider the RPG Outline view to be the best thing since sliced bread, enhancements to it always get our attention. In V9.5.1, there are several improvements and, in many cases, those improvements also impact features such as the hover-help information in the editor, hyperlink support and Content Assist. Since those features pull their information from the same place as the Outline, they also benefit from the latest improvements.
We'll cover our favorite of the enhancements first: the ability to hide unreferenced items. RPG Outlines tend to be very long and are often cluttered with definitions that exist in the program, but are not actually being used. The most common examples of this would be fields from externally described files and prototypes that were copied in from a generic source member that contained prototypes for dozens of routines. The capability to remove all that unreferenced clutter from the Outline makes it far more useful. Combine that with the filter box added in an earlier release and even a very long Outline becomes far more usable.
Figure 1 shows before and after views of the Outline for a program that has the standard prototype member for the CGIDEV2 tool copied into it using the new "Hide unreferenced definitions" icon.
In addition, more items from RPG now appear in the Outline, such a Control Statement (aka H spec or Ctl-Opt) section, an Output Statements section and an Exception Output section. Fortunately for us, we rarely need to work with RPG code that makes extensive use of O Specs and exception output, so we haven't had much experience with using these additions. If you are working with older style code, however, then the capability to see all the places that a particular output record is used in the logic, or to be able to jump to its exception output definition quickly, would seem to be a big help.
More Flexibility and Control
Some new preferences have been added to give developers more flexibility.
If you have ever made any syntax errors when coding, you are probably more familiar than you might like to be with the lovely pink error messages that get inserted into your code to tell you what you've done wrong. If you prefer a more subtle notification of syntax errors, you will be happy to know that now there is a preference to get those errors to appear as annotations, rather than insertions taking up extra space in your editor. The errors will have a red circle with an x in it. When you hover over the x, the error message appears—much like the way you see definitions of your variables in the code when you hover over them. If that idea appeals to you, then take a look for the page in Preferences under Remote Systems > Remote Systems LPEX Editor > IBM i Parsers and find the check box for "Display syntax check messages as annotations."
Content Assist support can now be made more automatic via a preference. Content Assist is typically invoked by a shortcut key (Ctrl + Space) and brings up suggestions for completing your statement. If you were a user of RDi's predecessor, WDSC, you may recall that when Content Assist was first introduced, it was automatic—that is, it constantly popped up with suggestions as you typed your code. Many RPGers found this too distracting, so IBM removed the automatic nature of the suggestions and changed it to require the use of the keyboard shortcut. Consequently, we suspect that most RDi users—including us—don't make use of Content Assist nearly as often as perhaps we could.
In response to a request for enhancement (RFE), IBM has now made it possible to partially re-enable this automatic support. Although not completely automatic, as it was in the initial incarnation, you can control this from the ILE RPG Content Assist preference page. You can find this by keying "Content Assist" into the Preference filter box. On that page you can specify the length of time in milliseconds (default is 500) before the suggestions appear and also the characters that should automatically trigger suggestions. The % and . characters are suggested characters. If you pause to recall the name of a built-in function after keying in the %, Content Assist will pop up a list of them. Likewise, if you key in the name of a qualified data structure followed by a . (period) you will get a list of subfields in that structure from which to choose. As an experiment, we tried adding a space to the list, and that results in Content Assist popping up all over the place. That quickly got a bit too much, so we removed it. If all this help is just too much for you, simply turn off "Auto Activation;" you will never see Content Assist suggestions unless you use the shortcut key.
A long-time RFE for RDi was the capability to make "Open for browse" the default behavior when opening a member from RSE (Remote System Explorer). That option is now a preference located under Remote Systems > IBM i > Objects Subsystem. Enable browse mode as the default by checking the "Open source in browse mode" check box.
If you use the program verifier with your RPG code and you have had to train yourself to ignore the error message you often get if you have DftActGrp(*No) in your control statement, then you will be happy to know that there is now an easy way to "fix" that issue. The reason for the error, by the way, is that the keyword is not supported when compiling with CRTRPGMOD, but it is perfectly valid for CRTBNDRPG. By default, the verifier by default chose to use the rules for CRTRPGMOD; while you could change that choice via a preference, it was too cumbersome to constantly change it back and forth. Most of us have learned to ignore the verify errors regarding the features only valid with one mode or the other. Now, if you select Verify (Prompt), you may choose which mode you want (CRTBNDRPG or CRTRPGMOD), and you may save that choice as your new default.
Refactoring your RPG code
In the most recent update (V220.127.116.11), we got the first option for code refactoring for RPG. Clearly, this is an area in which IBM hopes to improve. In this first iteration we have the ability to rename items in our RPG code—the names of variables, procedures, files or formats, etc. As we said in our blog post on this subject, this extends beyond a global find/replace of simple text. It understands that this is the name of a specific element and it recognizes the scope of definitions. Renaming a global variable named "Work" will have no effect on a local variable in a procedure in the same source member also named "Work;"however, if there is no local variable named "Work," then the rename will take effect on any references to the global variable in question. There is also a very useful Preview mode, which allows the developer to make sure the changes to be made are indeed the ones that are needed.
To see the effect of renaming a variable, we created a tiny program with a variable X that we will ask to rename to Y. After selecting the variable X in the source, we then right-clicked on Refactor > Rename, as shown in Figure 2. A dialog appeared where we keyed in the new name (Y) and clicked the Preview button. Figure 3 shows the side-by-side comparison of the original and refactored source. Pressing OK from the preview dialog then makes the proposed changes.
You can see that the occurrences of global variable name X were changed to Y, including the reference in the Like(X) keyword and in the logic, but changes to other names that included the letter X were not changed. Note also that references to X in the procedure ProcAuto were not renamed because there is a local variable there named X. If that local variable definition had not been there, then the reference to X in the procedure would have been refactored as well. It is also worth noting that changes are not made to comment lines.
The recent releases include additional changes of features we do not utilize in our normal work—we can't speak from experience about them. For those of you who use single-signon support via Kerberos, you'll be happy to hear that it will now work with RDi; you will not be required to sign on separately. This is controlled via a preference under Remote Systems > IBM i > Authentication, where you can specify Kerberos as your Authentication Option.
We're looking forward to more new goodies RDi as the enhancements keep on coming!
Like what you just read? To receive technical tips and articles directly in your inbox twice per month, sign up for the EXTRA e-newsletter here.