Monday, July 4, 2011

Setting a Range of Indicators Using a FOR Loop

Ok. Let's talk about indicators.  No matter what you do you still need indicators in RPG.  In fact, if you are using SDA and green screens you still need them. 

Over many years I found that I need more precision when dealing with indicators for green screens.  Normally I reserve indicators 1-39 for display files usage.  I also dedicate indicators 40-49 to store session independent status.  We can now use boolean variables of course but still it is nice to have indicators. Usually indicators 50-89 are reserved for field attributes.

In order to have more control over the setting of indicators I created the following sub-procedure SetInds:


      *  +----------------------------------------------------------------+
      *  + Function/Proc...:  SetInds                                     +
      *  + Type............:  SubProcedure                                +
      *  + Author..........:  Daniel Batista (DB Consulting)              +
      *  + Version.........:  1.0                                         +
      *  + Date Written....:  06/25/2004                                  +
      *  + Description.....:  Sets Indicators to True or False            +
      *  +                                                                +
      *  + Modification Log:                                              +
      *  +    06/25/2004.  Daniel Batista (DB Consulting)                 +
      *  +       - Created Original Version                               +
      *  +                                                                +
      *  +----------------------------------------------------------------+


     P SetInds         B
     D SetInds         PI
     D  lpiFrmInd                     3U 0 Const
     D  lpiToInd                      3U 0 Const
     D  lpiSetOnOff                    N   Const
     D  lpiUseNamInd                   N   Const Options(*NoPass)


      * ------> Local Variables
     D  lIx            S              3U 0


      /Free
         // --> Proceed To set Indicator Status
         For lIx = lpiFrmInd to lpiToInd;
            *In(lIx) = lpiSetOnOff;
            If %Parms() = 4;
               If lpiUseNamInd;
                  AllIndics(lIx) = lpiSetOnOff;
               EndIf;
            EndIf;
         EndFor;

      /End-Free

The prototype for this procedure is:
 
     D SetInds         PR
     D  FrmInd                        3U 0 Const
     D  ToInd                         3U 0 Const
     D  SetOnOff                       N   Const
     D  UseNamedInds                   N   Const Options(*NoPass)  


Please note the 4th parameter which is optional. If passed the procedure will also set the status of the named indicators area.  I always create a named indicator area with the module level array name AllIndics.  The named indicators area is defined like this:

      * Display File
     FDspFile   CF   E             WorkStn
     F                                     UsrOpn
     F                                     InfDs(dsWsFbck)
     F                                     IndDs(NamedIndics)
     F                                     Sfile(Sfl01:mS1RecNum)
     F                                     Sfil(SflD1:mD1RecNum) 

      * ------> Module Level Arrays
     D NamedIndics     DS
     D  AllIndics                      N   Overlay(NamedIndics: 1) Dim(99)
     D* Subfile Record and Control Indicators
     D in30_SflClr                     N   Overlay(NamedIndics: 30)
     D in33_SflDsp                     N   Overlay(NamedIndics: 33)
     D in34_SflEnd                     N   Overlay(NamedIndics: 34)
     D in35_SflNxtChgd...
     D                                 N   Overlay(NamedIndics: 35)
     D in36_SflMode                    N   Overlay(NamedIndics: 36)
     D
     D in39_ForceDisplay...
     D                                 N   Overlay(NamedIndics: 39)


This is how you use this:
         SetInds(50: 99: False: True);     // Clear Attribute Indicators

In this case we are setting indicators 50 through 99 to *OFF and we are also setting the named indicators area.

1 comment:

  1. bestair casino - bestairjordan11retro.com
    Find a top 10 bestair 올인 구조대 주소 casino reviews new air jordan 18 retro racer blue and air jordan 18 retro red my site discounts on bestair casino. We recommend them show air jordan 18 retro red all. Sign-up today! air jordan 18 retro men sale

    ReplyDelete

DirectSwift Directory URL Shack Web Directory