IBMi (AS400) fans only ' Modernizing RPG's indicator with INDARA (Indicator Area) keyword


#IBMiSample

INDARA (Indicator Area) keyword for ICF files

workstn indds
indicator data structure
INDARA is used to put the field option indicators and function(response) key indicators in a separate area of memory called indicator area.

By using this keyword, we can make indicator data structure in our program to give the customized name to indicators defined in the display file. Hence, it makes the program more readable and easy to understand.

Step 1. indicate INDARA 
keyword in your Display File



Step 2. indicate INDDS in your RPG workstation file declaration
dcl-f PKLTSFV workstn indds(Dspf) sfile(SFL1 : SF1NUM);


Step 3. declare the 
indicator area

       dcl-ds Dspf qualified ;

         Exit            ind pos(03) inz(*off);

         SflClr          ind pos(50) inz(*off);

         DspAtrRI        ind pos(61) inz(*off);

         DspClrRed       ind pos(62) inz(*off);

         SflEnd          ind pos(91) inz(*off);

       end-ds ;


   

Step 4. In the RPG source program replace all the indicator in the form *inNN or *inKK with the name defined in the indicator area,
for instance:
replace *in50 = *on with Dspf.SflClr = *on;
replace *in61 = *on with Dspf.DspAtrRI = *on;
replace *in03 = *on with Dspf.Exit = *on;
replace *inKC = *on with Dspf.Exit = *on;



Here's how to test and set indicators:

dcl-ds Dspf qualified ;                    
  Exit            ind pos(03) inz(*off)   ;
  SflClr          ind pos(50) inz(*off)   ;
  SflEnd          ind pos(91) inz(*off)   ;
end-ds ;                                   

dow Dspf.Exit = *off;
...
enddo;


Dspf.SflClr = *on;



That's it!





I appreciate all the comments made on this blog.













 

Comments

  1. As an aside - I RARELY code things as xxx = *on - I prefer the logical expression forms of xxx and NOT xxx. To me that is easier to read, and especially for developers that come from languages other than RPG it's easier to understand because it reads as a boolean. Indicators are unknown to developers of other programming languages, booleans are well known. I go so far as to define contants of "on", "off", "true" and "false" in a copybook in case I decide to use the explicit expression form. Cheers :)

    ReplyDelete
  2. how to use INDDS along with INFDS?

    ReplyDelete
    Replies
    1. Here's how to test and set indicators:

      dcl-ds Dspf qualified ;
      Exit ind pos(03) inz(*off) ;
      SflClr ind pos(50) inz(*off) ;
      SflEnd ind pos(91) inz(*off) ;
      end-ds ;

      dow Dspf.Exit = *off;
      ...
      enddo;


      Dspf.SflClr = *on;

      Delete

Post a Comment

Popular posts from this blog

IBMi (AS400) fans only ‘ Memories (IBM Coding Forms)

IBMi (AS400) fans only ' SQLCODE values: Dear readers, unleash your suggestions!