PMS Information Systems
Welcome to PMS Information Systems - IBM i (AS/400) Forum !!!

Get Answers for all your queries on IBM i (AS/400).

Name the Indicators - Tip1

View previous topic View next topic Go down

Name the Indicators - Tip1

Post  maran on Thu Feb 09, 2012 12:03 pm

This tip is an attempt to highlight four things that every RPGer should know about our little friends INDICATORS.

Indicators, or at least the standard set, are an array.


You may not need to use indicators *In01 - *In99 as an array, but the fact that they are an array offers an opportunity to name them with minimal effort.

I have always hated the fact that we have to rely on numbered indicators for display and printer files. The folks in Rochester have never given us an option to associate a name with them, which could work quite nicely with a variant of RPG's INDDS() keyword.

But there is an easy way in which you can associate an indicator with a name without having to use pointers to re-map the *In indicators. It takes advantage of the fact that *In01 is equivalent (i.e., it points to exactly the same byte in memory) as *In(01).

Assume for a moment that *In25 is used to indicate that an account is valid. So rather than use the number 25, if we set up a named constant called validAccount and give it a value of 25, we can then refer to *In(validAccount) and everyone who subsequently reads our code will have a much easier time of it. Like this:

d validAccount c 25

/Free

If *In(validAccount);
// Process account charges
EndIf;
Also we could add the actual indicator number to the end of the name like so: *In(validAccount_25). Now anyone who reads our code not only knows the purpose of the indicator, but also knows which indicator to look for in the DDS. The resulting code looks like this:

d validAccount_25...
d c 25

/Free

If *In(validAccount_25);
// Process account charges
EndIf;

avatar
maran
Admin

Posts : 442
Join date : 2009-07-24

View user profile http://pmsinformationsystem.forumotion.net

Back to top Go down

Re: Name the Indicators - Tip1

Post  razuk_r on Wed Feb 15, 2012 3:07 am

Nice one. Till now I am not aware of it Smile

razuk_r

Posts : 65
Join date : 2009-07-31
Location : Chennai

View user profile

Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum