Name the Indicators - Tip1
2 posters
Page 1 of 1
Name the Indicators - Tip1
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;
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;
Re: Name the Indicators - Tip1
Nice one. Till now I am not aware of it
razuk_r- Posts : 65
Join date : 2009-07-31
Location : Chennai
Similar topics
» Name the Indicators - Tip4
» Improve the performance of the RPG program - Tip1
» indicators in rpg/400
» Name the Indicators - Tip2
» Name the Indicators - Tip3
» Improve the performance of the RPG program - Tip1
» indicators in rpg/400
» Name the Indicators - Tip2
» Name the Indicators - Tip3
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum