You are currently on IBM Systems Media’s archival website. Click here to view our new website.

IBM i > DEVELOPER > RPG

Susan's Favorite New RPG Feature

Last month was Jon’s turn to share his favorite RPG feature. Now it’s Susan’s turn. RPG expert and IBM Systems Magazine, Business Systems edition Technical Editor Susan Gantner shares her thoughts on RPG without numbered indicators.


 

In our blog entry for April 29th (http://ibmsystemsmag.blogs.com/idevelop/2008/04/breaking-old-rp.html), Jon and I mentioned that we’d discuss our favorite “new” RPG features in our next EXTRA column. Jon told you about the MONITOR opcode last month (www.ibmsystemsmag.com/i5/enewsletterexclusive/20423p1.aspx) and this month, I’d like to share the cure for my pet peeve—numbered indicators. Is there such a thing as “indicatorless” RPG? Yes!

I should clarify that there's nothing wrong with using an indicator to store the answer to a yes/no question. But I draw the line at using numbered indicators for that purpose. Now that we have a language where we can have field names long enough to be meaningful, there’s no place for a name as meaningless as 47 or 82. Why not ProdNo_Error or SflClear or %EOF instead? We've written about some of these techniques before, but since we still see a lot of code—and newly written code at that—with numbered indicators in it, I just have to revisit some of the ways to stop using numbered indicators.

Numbered indicators have traditionally been used in many ways, so it takes many ways to replace them. Those of you who’ve begun coding in /Free format logic have learned by now how to replace many indicators with RPG built-in functions. Functions such as %EOF, %Found, %Equal and %Error (with its corresponding E extender) let us replace most of the right-hand resulting indicators from our past. I hope none of you would even dream of writing a new program that used some of the old-style operation codes that require the use of resulting indicators, such as COMP or TESTN. Built-in functions can be used to replace the need to use resulting indicators for all modern operations. A pretty good rule of thumb as to whether an operation code is considered modern is if it can be used in /Free form.

What about those indicators from DDS display files? We’ve seen three techniques commonly used to replace the DDS indicators in our RPG programs. Unfortunately, we can't easily replace the use of numbered indicators in the DDS, but we can replace those numbers with names. Let's look at a few ways to do that.

 

Susan Gantner is a technical editor with IBM Systems Magazine and co-owner of Partner400.



Advertisement

Advertisement

2019 Solutions Edition

A Comprehensive Online Buyer's Guide to Solutions, Services and Education.

New and Improved XML-INTO

Namespace support makes the opcode a viable option

Authenticating on the Web

The finer points of OpenRPGUI, Part 1

The Microphone is Open

Add your voice: Should IBM i include open-source RPG tools?

IBM Systems Magazine Subscribe Box Read Now Link Subscribe Now Link iPad App Google Play Store
IBMi News Sign Up Today! Past News Letters