VisualAge RPG
  For many years this was a section on my Programming page, but I haven't used VARPG in years, and it may not even be still available from IBM, so I removed it and put it on a separate page.
  For several years, beginning in 1995, I used IBM's VisualAge RPG to develop client/server applications. We used to do VARPG presentations and labs with Larry Schweyer and Claus Weiss of IBM at COMMON (perhaps I've even met you there). Since Safety was a beta site for their VARPG development tool we had a special relationship with the Toronto lab, and IBM created a case study webpage about us (and Claus, they misspelled my name).

 VARPG programming tips
  Changing the default action on a project's .ivg file

I liked to put my VARPG projects on a Windows menu, and by selecting the menu option have the GUI designer open the project. By default, if you select a shortcut to a project, or if you double-click on the .ivg file in Explorer it will open up a folder showing you the project's files.

You can change this action with a setting in the Windows registry.

  1. Start Regedit.
  2. Open HKEY_CLASSES_ROOT\ivgfile\shell.
  3. In the right panel, double-click on the entry that says (Default).
      Value data: 'Open,Edit,EditP...'
  4. Switch the order of the items to have Edit first.
      Value data: 'Edit,Open,EditP...'
  Calling a Windows API

When I first used VARPG it was OS/2 based, and since OS/2 didn't have a taskbar like Windows it had a slightly bigger viewable area of the screen. This is not an issue in most situations, but on the 14-inch monitors with 640x480 resolution that were common back then, I found it limiting. I had created one non-scrollable window that was so big and full of graphics and essential information that when I ported the application over to Windows 95, if the user had the Taskbar property set to be Always on top (my personal preference) the bottom of the window would be hidden behind the taskbar. I decided that rather than require every user of this software to turn off this taskbar setting, or make the taskbar Auto hide, I had to create an Always on top menu option for my window so it could overlay the taskbar (saving this setting for future returns to this screen of course). The way to do this is to call a Windows API to make the window first in the Z-order. I posted this tip on the website (which I believe is long gone).

This code sets the Always-on-top mode of a window.

* Prototype the Win32 API function * The values for the Z-Order parameter (hwndInsertAfter) are: * 1 = Bottom most position in the stack of child windows * -2 = Bottom position of all topmost windows, above all nontopmost windows * 0 = Top position in the stack of child windows. * -1 = Top position of all topmost windows. D SetWinPos PR 1B 0 ExtProc('SetWindowPos') D DLL('USER32') D Linkage(*StdCall) D 10U 0 Value Handle D 10U 0 Value Z-Order D 10I 0 Value x D 10I 0 Value y D 10I 0 Value cx D 10I 0 Value cy D 10I 0 Value flags D hWnd S 10U 0 D flags S 5U 0 Inz(3) D bRC S 1B 0 * Get the window handle. C eval hWnd=%getatr('WIN01':'WIN01':'Handle') * To set the Window to be topmost in the Z-order: C eval bRC=SetWinPos(hWnd:-1:0:0:0:0:flags) * To set the Window to NOT be topmost: C eval bRC=SetWinPos(hWnd:-2:0:0:0:0:flags)

You can also call AS/400 API's, but after developing a nice GUI interface to allow users to maintain their AS/400 passwords I found out the hard way that you can run into authority problems in that area.

  Blinking text

Surprisingly, VARPG doesn't have a Blink attribute for any parts. To achieve a blinking affect you alternate the Visible attribute of a part between ON and OFF, using a timer part and the TICK event. This technique works for any kind of situation where you want to toggle a visual display. I have also used it to alternate images associated with a part to produce animation. To use it, create a timer part on the window with the Visible attribute set to OFF. Experiment with the Interval and Multiplier attributes to achieve the timing you want. Be aware that since VARPG is single-threaded, depending on what else is occurring in your application you may not always get a perfectly timed blinking effect. The timer can be used for other types of animation, for instance, you can alternate images or change the location (left, top, and bottom attributes) of a part on the window canvas.

Uses the TICK event to blink the text.

* Turn on the timer to start generating TICK events. C eval %setatr('WIN01':'TIMER1':'Timermode')=1 * Toggle the visible setting for the text. C timer1 begact tick win01 C 'TEXTPART' getatr 'Visible' vis 1 0 C if (vis = 1) C eval %setatr('WIN01':'TEXTPART':'Visible') = 0 C else C eval %setatr('WIN01':'TEXTPART':'Visible') = 1 C endif C endact

  Create macros for the LPEX editor

The LPEX editor used by VARPG and CODE is easily customizable with Rexx macros. I have added a menu called Custom that has options on it I want to use often, most having hot-key mnemonics.
To use the menu macro, Custom.lxl, add the line 'macro custom.lxl' (include quotes) to the Profile.lx macro (to edit click on Options » Profiles » User preferences) so that it is loaded when you start the editor. The macros must be located somewhere on the LPATH (a registry setting*), which you can view by typing 'query lpath ' in the command dialogue (Actions » Issue edit command). I keep my own macros in 'C:\MyMacros', a different location from IBM's, so that they won't get clobbered by upgrades to VARPG. To add this folder to the LPATH, I typed 'extras on c:\mymacros' in the command dialogue.
Here are 3 of my macros.
  • Custom.lxl – menu macro
  • WinPos.lx – open editor window in preset size and location, cascade if second window
  • PrevPos.lx – return to previous position in source
Some of the options on my Custom menu call macros that come with VARPG, for instance, the option Match begin-end calls match.lx to identify a logic block. If you haven't discovered this IBM macro, you will be amazed how useful it is. Since the mnemonic Alt-m is set up when my menu is loaded, all I have to do is put the cursor on an IF or DO statement, press Alt-m, and the matching END (or ENDIF, ENDDO) will be located with the entire block highlighted. Conversely I can put the cursor on an END statement to locate the corresponding IF or DO.

Custom.lxl also sets up some other useful RPG actions. If I double-click on a line of code the entire line is highlighted, making cutting & pasting RPG code very easy. Since RPG is a columnized language, pressing Enter to create a new line can cause a problem by breaking up your code if you do this when the cursor is not at the end of a line. I have solved this by creating options to insert a blank line Before (Alt-i) or After (Alt-a) the current line.

And of course, I have also modeled on some SEU actions, Alt-b will go to the bottom of the source and Alt-t will go to the top, and Alt-d will duplicate the current line, making it unnecessary to copy & paste the current line to repeat the code. I have added a toolbar icon for Find next to repeat the most recent Find operation, so you can just click to repeat (like F16 in SEU). Look for it next to the little flashlight icon for Find.

     VARPG related links
VisualAge RPG
     Windows Tips and Techniques
Programming with VisualAge for RPG – the Redbook
The Rexx Language
LPEX User's Guide and Reference