Guru: RDi V9.6 Part 7 – Zoom in, Know Where You Are, Refactor Constants and More
May 11, 2020 Susan Gantner
RDi enhancements just keep coming. Since my last installment in this series on V9.6 there have been more fix packs and quite a few new features. Here in part 7 I’ll cover refactoring character constants, two ways for RDi to indicate “you are here”, and a small but really useful way to zoom in on your code. Plus a small bonus item for those who do their compiles in batch.
You Are Here!
Two new features were added in 184.108.40.206 that act a bit like those “you are here” indications on maps. When editing RPG code, it tells you if you’re in the mainline code or what subroutine or subprocedure you’re in.
The name of the routine or (Main Procedure) appears in the message area at the bottom of the editor window. In addition, you can have the Outline view position itself automatically and highlight the appropriate routine as you move through the code. Both features are illustrated in Figure 1 below.
It’s probably a bit overkill to have both of those features active at the same time so decide which works best for you. The message at the bottom of the editor is on by default but can be turned off via an option on the main ILE RPG preference page. (Note that the fastest way to get there is via the Preferences option from the Outline view menu). The option you’re looking for is “Show current procedure or subroutine in editor” near the bottom of that page.
Just below that option on the preference page is “Select current procedure or subroutine.” That is the one that controls the Outline view action. That preference can also be accessed via an option from the Outline view menu. I believe it is not turned on by default.
Sometimes it’s nice to make the source code you’re working on in the editor a bit bigger. Maybe you’re showing something to a colleague looking over your shoulder or maybe you’re just having one of those days when you’re having trouble focusing. Or in these days of working from home, perhaps sharing code over a video link. While you could always change the font size in the editor by using preferences, that’s a lot of trouble if you just need a temporary boost in font size. As of 220.127.116.11 you have the ability to zoom in on a specific open member using the keyboard shortcut Ctrl + (or on a Mac, use command +). (See Figure 2.) Keep pressing the + until you get the font size you want. When you’re ready to make the font smaller again, use Ctrl – (or command – on Mac). Note that the font only changes on the member you’re currently looking at – any other open members stay the same.
Refactor Constant Text
Help with refactoring code is always helpful. A couple of years ago, the refactoring menu in the editor appeared with an option for renaming things such as variables. As of 18.104.22.168 a second refactoring item appeared in that menu – Extract constant . . . (Note that if you have 22.214.171.124 or later installed, you’ll also see a third menu entry for Extract Procedure. . . . I’ll be covering that in a later tip.)
We all know that it’s far better to use named constants instead of literal values in our code, especially if there is (or may be) more than one reference to the value. This new support makes it much easier to implement named constants after the fact in your code. It will not only create the constant definition for you, it will also replace all references to that same constant value in the code. So far, this option only works for text constants. I’m hoping we’ll see a similar feature for numeric constants at some point in the future.
If you’re familiar with the rename refactoring option, the extract constant option will feel very familiar. For those who may not have used rename, here’s how the process works.
First, select some constant text in your code (i.e., some text in quotes). You don’t need to select the entire constant value – selecting any part of it is fine. Next, right click and choose Refactor > Extract constant… and you will get the Extract Constant dialog box. A suggested name for your named constant will be filled in, but you can modify that to whatever you want. These steps are illustrated in Figure 3.
If you want to preview the refactoring changes that will be made, you can do that either by ticking the
“Force preview” box or hitting the Preview button. Alternatively you can hit “OK” and all the changes will be made automatically in your editor view. Of course, you can always undo those changes if you decide after the fact that it wasn’t exactly what you wanted. A picture of the preview dialog appears in Figure 4.
Do You Compile in Batch?
Personally, I don’t like to do my RDi compiles in batch. I have set my preference to compile in my RDi connection’s job. If you want to give that option a try, go to Preferences > Remote Systems > IBM i > Command Execution and de-select the “Compile in batch” box.
However, I’m sure there are many of you out there who prefer the default behavior of submitting compiles to batch. Prior to 126.96.36.199, the job name for those submitted compiles was different from the name that a PDM batch compile used. Now it will use the name of the source member — exactly the same behavior that PDM has. So now your batch compile jobs will be consistently named if you switch back and forth between compiling in PDM and RDi.
There are many more enhancements that have been added to RDi 9.6. These include some nice enhancements to existing features as well as refactoring support for creating subprocedures from existing logic that I mentioned earlier. There is also a new view that makes modifying your library list easier. I’ll explore those and other new RDi enhancements in later tips