Bookmark and Share

Recent Posts

Christmas Comes Early for RPGers

December 09, 2016

Yes, it is true: the elves at the Toronto Lab have given us an early Christmas present and, best of all, you can unwrap it and play with it right now, as long as you are running V7.2 or 7.3 anyway. We thought while we were on the topic of RPG, we'd also take the opportunity to ask for your support for Jon's latest "wish" for RPG.

And RPG's 2016 Present is ...

The new feature is known as ON-EXIT and basically it allows you to write a piece of code that will always be executed when a procedure ends, regardless of whether it completed normally (i.e., you executed a Return operation) or if it blew up for some reason. This gives you the ability to clean up at the end of a process. Perhaps to close files, close a network connection, deallocate dynamic memory, or ... well you get the picture. To say that we could have used this feature in a project we were working on some 18 months or so ago is to put it mildly.

We had originally planned to include a few code samples here, but Barbara Morris has done a good job of providing examples on this web page in the RPG Cafe on DeveloperWorks. In addition, Simon Hutchinson has just published a nice article on his RPGPGM blog on the topic. As a result we're going to hold off on publishing our own thoughts on the topic until we have had more time to work with it in a practical context.

This type of enhancement is exactly the kind of thing we like to see IBM doing; things that we can't do, or can't do simply, for ourselves. One last point: the RPG Cafe piece referenced earlier is also the place to go to for details of the required PTFs.

Please Vote For ...

Hopefully asking you to vote for Jon's latest RPG enhancement request will prove less controversial than voting in the recent U.S. election--but you never know!

This latest RFE arose from us seeing the difficulties that many RPGers faced when they started to embrace modular programming, and subprocedures in particular. When subprocedures were first introduced, IBM decided to make it as easy as possible to move from coding subroutines to subprocedures. That required local subprocedures to have full access to all globally defined variables in the program. This made sense in that, at the time, files could only be defined globally and therefore if I/O operations were to be permitted at all in subprocedures then access to global definitions was essential.

Over time of course, RPG has evolved and the necessity for access to global variables has pretty much disappeared. But of course the compiler writer’s dilemma comes into play here and, for compatibility reasons, IBM cannot simply take such a feature away or they would break large numbers of programs.

The idea behind this new feature is two-fold: first to make it easier to avoid shooting yourself in the foot by accidentally referencing global variables; secondly to allow RPG programs to be more self-documenting by allowing the programmer to specify that a specific subprocedure (or indeed a no-main collection of subprocedures) can only reference specified global variables. Once such a declaration has been put in place, the compiler will diagnose and issue an error if any attempt to reference a global variable is made.

Rather than go any further into the details here, please go to the RFE page and, if you like the proposed feature, vote for it! (Note: You will need an IBM ID to access the RFE page.)

While you are there have a look around and see what other features have been requested for RPG. And if you don't see your pet feature, create it! Anyone can instigate an RFE and IBM is listening. In fact IBM would love to see more comments on the proposed features to help them to determine how the community feels about a specific request.

Posted December 09, 2016 | Permalink

Post a Comment

Note: Comments are moderated and will not appear until approved

comments powered by Disqus