ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Dynamically allocate the length of a variable

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

  • Dynamically allocate the length of a variable

    Hi

    Can it be possible to assign the length of the variable at runtime i.e Dynamically allocate the length of a variable?

    Suppose I have two variable A & B of 20 lengths and at runtime the value may â??testingâ?? is assigned to that variable A. Then I want the variable B should be come in 7 length field.

    Mean the value of variable B should be â??testingâ?? Not â??testing â??



    Thanks in advance.


    Skma

  • #2
    Re: Dynamically allocate the length of a variable

    maybe you could just use %len , %trim and %subst ????

    This would equal 7

    Bigfield = 'testing '
    length = %len(%trim(Bigfield))

    you could then use substring to move it somewhere else
    or just %trim to add it to another string


    jamie
    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: Dynamically allocate the length of a variable

      Define the variables as "varying" on the D specs. So A= "testing" has a length of 7 and B= "test" has a lenght of 4.
      Hunting down the future ms. Ex DeadManWalks. *certain restrictions apply

      Comment

      Working...
      X