ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

%Trim, %SUBST ???

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

  • %Trim, %SUBST ???

    I have a field that is character size 14. I will call that field NRNUM. In the 7, and 8 positions of that field (which is an item number) is the length of the item. In positions 9 and 10 is the width position. How do I go about plucking those out into numeric fields of size two named HEIGHT AND WIDTH? This is what I tried, but it won't compile....

    PHP Code:
         C                   EVAL      WIDTH = %TRIM(%SUBST(NRNUM:7:8))
         
    C                   EVAL      LENGTH = %TRIM(%SUBST(NRNUM:9:10)) 
    I'm guessing I need to wrap the whole thing in a %dec() too then to make it numeric...
    Your future President
    Bryce

    ---------------------------------------------
    http://www.bravobryce.com

  • #2
    Re: %Trim, %SUBST ???

    I'm wearing my big boy pants today! I figured it out. Thanks for looking
    Your future President
    Bryce

    ---------------------------------------------
    http://www.bravobryce.com

    Comment


    • #3
      Re: %Trim, %SUBST ???

      I hope it was something like

      width = %int(%trim(%subst(NRNUM:7:2)))

      Comment


      • #4
        Re: %Trim, %SUBST ???

        very close....

        WIDTH = %dec(%SUBST(NRNUM:7:2):11:3)

        I changed it into an 11 : 3 since that is what it was ultimately going to end up in when it gets put in the file. no trim needed either.
        Your future President
        Bryce

        ---------------------------------------------
        http://www.bravobryce.com

        Comment


        • #5
          Re: %Trim, %SUBST ???

          Hi,

          what about defining a datastructure for your field NRNum?

          PHP Code:
          D DSNrNum           DS
          D   NrNum                                14A
          D     Width                               2S 0  overlay
          (NrNum7)
          D     Length                              2S 0  overkay(NrNum9
          Birgitta

          Comment


          • #6
            Re: %Trim, %SUBST ???

            Interesting....I didn't know about that technique. Saves me from having to call those BIFs 20,000 times. I might look into that.....would it help speed up processing?
            Your future President
            Bryce

            ---------------------------------------------
            http://www.bravobryce.com

            Comment

            Working...
            X