Quickly Open Source Members In Rational

I've been using Rational to edit CLLE and RPGLE source for some years now, but if I wanted to quickly view a specific source member I would often fall back to a Client Access session, and use one of our custom commands, DS (Display Source) to quickly display the member in SEU. Our DS command determines the source library, file, and member used to create an object, and then opens it, so it's a really fast way to view the source for any object. That being said, viewing source in Rational is so much better than using SEU, so I wanted to find a quick way of opening a member that I was interested in.

I have a tendency to obsess about the fastest way to perform pretty much any given task, and after years of typing DS xxxxxxxxxx to view the source for xxxxxxxxxx, I find it particularly irksome to have to bring up the "Open Member" dialogue, enter a source file, library, member, and since we're usually viewing a production source member, I have to select the "Open For Browse" option.

Now I'm sure there is a way to write some sort of eclipse plugin that could improve this process, but being a busy developer working on tight deadlines, I looked for the quickest solution to my problem, and turned to Autohotkey to do some of the heavy lifting for me.

Autohotkey is a great tool with many uses, including the ability to playback keystrokes when a specific Hotkey is pressed. With this in mind, I added the following to my Autohotkey script, which is activated when Alt+o is pressed and Rational is the active window:

Rational := "Remote System Explorer" 
!o:: 
{ 
SetTitleMatchMode 2 
if winActive(Rational) { 
InputBox, UserInput, Open Member, Please enter member name, , 200, 120 
if (UserInput = "") {
 return 
} 
pre := SubStr(UserInput,1,2) 
SendMode Input 
Send {Shift Down}{Control Down}A{Control Up}{Shift Up} 
send {tab 3} send {right} send {tab 5}

send PRODSRC

send {tab 3} 
if (pre = "CL" || pre = "cl") { 
send QCLLESRC 
} 
else { 
send QRPGLESRC 
}

send {tab 3} 
send %UserInput% 
send {Enter}

} 
return 
}

Essentially the script does the following:

  • Prompts for the source member name
  • Triggers the "Open Member" dialogue
  • Sets the library to be PRODSRC (Our production source library) since that's the most likely location of the source
  • Sets the source file to be QCLLESRC if the entered member begins with CL (Thank you whoever started that naming convention), otherwise it sets the file to QRPGLESRC
  • Sets the member name to be whatever was entered.
  • Selects "Open in Browse"
  • Presses the Enter key

I did find that there was an occasional issue rolling this script out to other members of my team - sometimes other actions conflict with the default key binding of the "Open Member" dialogue (Shift+Ctrl+A), so we either resolved the conflict, or mapped another key combination to this action (e.g. Ctrl+O) and adjusted the script as appropriate.

This is just a first cut at the script, and I have a lot of ideas to make it more useful (Like making it easy to open a DDS source member), but even in it's current state I'm now a lot more likely to browse source in Rational, and that has to be a good thing.

If you've made any other hacks to make working in Rational quicker or easier then contact me on twitter, or leave a comment below.

/
If you found this post informative, enlightening, entertaining, or it's just helped you solve a problem then please feel free to shout me a coffee for my trouble from extensive menu below:
Today's Menu