ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

%Subst and *IN

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

  • %Subst and *IN

    Whenever i want to check to see if all indicators between IN31 and IN39 are off and I use If %Subst(*IN:31:9) = *ZEROS I get errors like:

    Array has too many omitted indexes; specification is
    ignored.

    Is there a way to do this with %subst. The obvious way is If *IN31 = *OFF and *IN32 = *OFF and *IN33 = *OFF.......... but that can get tedious if there are a lot of indicators. Would like to use %subst if possible

  • #2
    Re: %Subst and *IN

    Hi Gregwa50:

    Try this:
    if %SubArr(*IN: 31: 9) = *Off;
    see here:
    http://www.code400.com/forum/showthr...ghlight=subarr

    Best of Luck
    GLS
    The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

    Comment


    • #3
      Re: %Subst and *IN

      Try this:
      if %SubArr(*IN: 31: 9) = *Off
      produces the following error:
      Array has too many omitted indexes; specification is
      ignored.

      Comment


      • #4
        Re: %Subst and *IN

        Not sure why %SUBARR doesn't work here. (Barbara might know.)

        But you could do it like this:
        Code:
        D p_Indic         s               *   inz(%addr(*IN))  
        D Indic           ds                  based(p_Indic)   
        D                                     qualified        
        D   range31to39                  9a   overlay(Indic:31)
                                                               
         /free                                                 
            if Indic.Range31to39 = *Off;   // or *ZEROS
              .
              .
        Personally, though, I think the best fix is to eliminate the use of so many indicators! The only place I ever use numbered indicators (at all) is when communicating with display files -- if that's what you're doing, it might be better to use INDDS instead.

        Comment


        • #5
          Re: %Subst and *IN

          %SUBARR returns an array, and you can't compare an array.

          You could use %lookup:

          Code:
             if %lookup('1' : *in : 31 : 9) = 0;
                // there are no '1's in that range

          Comment


          • #6
            Re: %Subst and *IN

            I like the DS approach better :-)

            Comment

            Working...
            X