Problem solve Get help with specific problems with your technologies, process and projects.

A simpler way to name RPG indicators

Here's a simpler way to name RPG indicators.

Two techniques for naming RPG indicators are well known. Using INDARA in the display file has some side-affects that might require more coding to work around. Using a based array to overlay the built-in indicator array *IN can be hard to understand for those not used to working with pointers. Both techniques can impact maintainability because it's not obvious when an *IN indicator is being referenced.

Here's one I've never seen offered. I think it benefits from being simpler than other methods, and it has no side affects.

Use named constants to name the indicator array index values:

d exitKey c 3 d promptKey c 4 d cancelKey c 12 c if *in( exitKey ) c exsr exitPgm c elseif *in( promptKey ) c exsr callFinder c elseif *in( cancelKey ) c exsr return c endif

Dig Deeper on RPG iSeries programming

Join the conversation

6 comments

Send me notifications when other members comment.

Please create a username to comment.

Need to read article a simple way to name RPG Indicators
Cancel
seems to be about as much work to setup and use the named constants as it is to use the indicator data structure (INDARA method).  As far as recognizing indicator usage, then just use a naming convention.
Cancel
I would have to agree with BigKat.
Sometimes we try to hard to make it "easy".
Change just for the sake of change is not necessarily a good thing.
Cancel

Same here, I have to agree with BigKat and CharlieBrowne. No need to reinvent the wheel. Seasoned programmers may find it even more difficult if the new renaming is not clear.

Personally the only time I needed something like this was when some of our programs ran out of the 99 available indicators and we needed to create our own.

Cancel
Not that difficult to set up - a /COPY with the necessary D specs gets it for all programs that need them, but even so have to agree with you guys not much benefit.
Assuming your shop has a standard for function keys in displays (eg F3=Exit - always!) then it doesn't take long for everybody to learn what "IF *IN03" will do.
And with the ability to define named Boolean variables (type N), I've never needed more of the old numbered indicators (*IN01-*IN99) than I can count on my fingers.

I've used (free) code like this:
CHAIN (Key) Record;
RcdLck = %found();
// more processing
IF RcdLck;
UPDATE Record;
ELSE;
WRITE Record;
ENDIF;

and if you define a separate RcdLck variable for each update file you never get confused. :-)
Cancel
Am I the only one not using indicators for function keys?
Cancel

-ADS BY GOOGLE

SearchDataCenter

Close