ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Indicators

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Indicators

    Hi,
    How to set on/off a group of indicators in a single statement?

    Thanks,
    sateeshs

  • #2
    Re: Indicators

    PHP Code:
    C                   MOVEA     *ON           *IN            
     C                   MOVEA     
    *ZEROS        *IN(40)        
     
    C                   DUMP                                    
     C                   
    EVAL      *INLR = *ON                  

    Dump shows indicators 40 
    and above are all off

    Code:
    D IndDsPtr        S               *   Inz( %Addr( *IN ))  
    
    D IndDs           DS                  Based( IndDsPtr ) 
    D  SflClear              21     21n
    D  SflCtlDsp             22     22n
    D  SflEnd                23     23n
    D  AcctError             70     70n
    D  zipError              71     71n
    D  stcdError             72     72n
    D  ErrorInd              70     99
       ...
       // Reset all error indicators (70-99)
       ErrorInd = *All'0';
    Code:
     reset all indicators
    *IN = *all'0';
    more indicator stuff:

    I found this just searching around and thought I'd share
    from :KENNETH TARR (search400)

    Naming your numeric indicators used in screen displays or printer
    files is an effective way to make your programs more readable and
    understandable, but did you know there are two ways it can be done?
    The first method is associating a data structure using the INDDS keyword,
    and the second method is by address association using the BASED keyword.

    The first method uses the INDDS keyword which references a data structure.
    Within the data structure you give each indicator you use a unique name.
    So instead of saying IF *IN99 = *ON, you can say IF ERROR = *ON.
    This provides someone who has never been in the program before a
    better understanding of what the test is, instead of having to
    hunt down every occurrence of the indicator and figure it
    out from there.


    PHP Code:
    ~

    FWS1234DF  CF   E             WORKSTN INDDS(Indicators)


    DIndicators       DS                                      
    D InPageUp            25     25N                       
    D InPageDown          26     26N                       
    D InSflDspctl         40     40N                       
    D InSflDsp            41     41N                       
    D InSflClr            42     42N                       
    D InSflEnd            45     45N                       
    D InPC_Run            60     60N                       
    D InPC_ChkDt          61     61N                       
    D InPC_Cntrl
    #         62     62N 
    The keyword INDDS references a data structure named Indicators.
    The data structure is a length of 99, but you don't need to
    specify every indicator, only the ones you're using. Additionally,
    the keyword INDARA needs to be present in the display or printer
    file you're referencing. The data structure can be referenced by
    more than one display and/or printer file within the program.
    You can also create separate ones for each.
    The second method uses the BASED keyword. It is similar to the
    first method except it does not require changes to the file
    specifications or either the display or printer files; all the
    changes are in the data structure, like so:

    PHP Code:
    ~
    DIndicators       S               *   INZ(%Addr(*IN))         
    D                 DS                  BASED(Indicators)       
    D InPageUp            25     25N                       
    D InPageDown          26     26N                       
    D InSflDspctl         40     40N                       
    ... 
    Here, the built-in function %ADDR references the Indicator array,
    and BASED references the data structure you provide.

    A difference between the two methods is that the first method can
    refer to a different data structure for each display and/or printer
    file you use, whereas the second one would apply to all.

    Here's an added tip, regardless of which method you use. You are not
    restricted to one name for each indicator. It is possible to supply
    multiple names for each. For example if indicator 50 is used to
    condition a field on two different screens, each with a different
    meaning, you can specify something like this within the data structure:

    PHP Code:
    ~
    D InPosCursor         50     50N
    D InInvCustomer       50     50N 
    This way you're not stuck using a name in another part of the program
    that isn't the intended meaning. A word of caution however, as when you
    condition one of the named indicators above, it affects both when they're
    sharing the same indicator within a data structure. As long as this is
    kept in mind when designing the program, you'll be OK.
    All my answers were extracted from the "Big Dummy's Guide to the As400"
    and I take no responsibility for any of them.

    www.code400.com

    Comment


    • #3
      Re: Indicators

      Code:
           D IndDs           DS                  Based( IndDsPtr )
           D  SflInds                            Overlay(IndDs: 21)
           D  SflClear                       n   Overlay(SflInds)
           D  SflCtlDsp                      n   Overlay(SflInds: *Next) 
           D  SflEnd                         n   Overlay(SflInds: *Next)
      You might want to try this approach as an alternative - it avoids the From/To notation and also allows for groups of indicators.

      Please DON'T use MOVEA becuase:

      A) It is non-intuitive and while the examples above are not too bad the evil MOVEA '001101010011'*IN20 type of usage is never far behind!

      B) MOVEA doesn't exist in /Free nor will it will not be there in any future versions of RPG.

      JonP

      Comment


      • #4
        Re: Indicators

        Originally posted by JonBoy View Post
        Code:
             D IndDs           DS                  Based( IndDsPtr )
             D  SflInds                            Overlay(IndDs: 21)
             D  SflClear                       n   Overlay(SflInds)
             D  SflCtlDsp                      n   Overlay(SflInds: *Next) 
             D  SflEnd                         n   Overlay(SflInds: *Next)
        You might want to try this approach as an alternative - it avoids the From/To notation and also allows for groups of indicators.
        Normally I would agree with you. If this was a normal Data Structure then this would be the way to go.
        However using this version:
        Code:
        D IndDsPtr        S               *   Inz( %Addr( *IN ))  
        
        D IndDs           DS                  Based( IndDsPtr ) 
        D  SflClear              21     21n
        D  SflCtlDsp             22     22n
        D  SflEnd                23     23n
        D  AcctError             24     24n
        D  zipError              25     25n
        D  stcdError             26     26n
        Makes finding the screen indicator a whole lot easier.

        Mikes
        You don't stop playing games because you get old, You get old because you stop playing games!

        Comment


        • #5
          Re: Indicators

          No argument - although one of our trainees came up with an idea the other day that I've been playing with - which is to use a name for the indicator but include the indicator number as the last two characters e.g. SflClear21, SflCtlDsp22, etc.

          Of course in most cases like your example where no group fields are required you can use overlay to achieve the same thing and personally I prefer it to From/To

          Code:
          D IndDs           DS                  Based( IndDsPtr ) 
          D  SflClear                           Overlay(IndDs: 21)
          D  SflCtlDsp                          Overlay(IndDs: 22)

          Comment


          • #6
            Re: Indicators

            Originally posted by JonBoy View Post
            No argument - although one of our trainees came up with an idea the other day that I've been playing with - which is to use a name for the indicator but include the indicator number as the last two characters e.g. SflClear21, SflCtlDsp22, etc.

            Of course in most cases like your example where no group fields are required you can use overlay to achieve the same thing and personally I prefer it to From/To

            Code:
            D IndDs           DS                  Based( IndDsPtr ) 
            D  SflClear                           Overlay(IndDs: 21)
            D  SflCtlDsp                          Overlay(IndDs: 22)
            All valid points. As usual it depends on the situation...

            I've never considered the Overlay method for indicator DS before, looks a lot more readable. I'll try that method next time.

            Cheers

            Mike
            You don't stop playing games because you get old, You get old because you stop playing games!

            Comment


            • #7
              Re: Indicators

              Gee and what's wrong with naming your indicators *IN21. It is a unique name and you know exactly which one it is. with good documentation it works. And you can't use the descriptive name in the screen definition.

              Bill (AKA Devils advocate)...
              (JK I know the value of using a real meaningful name)
              Bill
              "A good friend will bail you out of jail,
              A true friend would be sitting beside you saying,
              'Wow, that was fun.'"

              Comment

              Working...
              X