How to loop through a list in ITERATE action in Xlate?

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf How to loop through a list in ITERATE action in Xlate?

  • Creator
    Topic
  • #54996
    Sucharitha Manyala
    Participant

      I have a requirement to add OBX segments based on OBX_5 field value. OBX_5 field is a String field that has multiple values separated by double back ticks( like “Val1 “ Val2 “ Val3) and I need to split that field based on double back ticks, loop through the new list values and add new OBX segment for each list value. I could split OBX_5 using textutils’s splitx command but I need help looping through the resultant list using ITERATE action in Xlate. I tried giving list variable in “Basis” section and “%l1” in “Variable” section but that doesn’t seem to be working. Since I need to set entire OBX segment for each list value I can’t just call a tcl proc to loop through the resultant list. Any help is greatly appreciated.

    Viewing 1 reply thread
    • Author
      Replies
      • #83726
        Jim Kosloskey
        Participant

          You will need a Tcl proc that ‘pops’ the top elelment from the list each time it is invoked. I have one. If you want it email me.

          Then what I do is use a basis of ‘0 1’ (no quotes). This is then a basis of 2. Let’s say the counter is %l1.

          Inside the ITERATE then I would (using the proc I have) invoke the Tcl proc which should give me back the top element and the remainiing list.

          I would check to see if the value returned was null (what the proc I have returns when the list is empty).

          If that is true then I would set %l1 to 2 ( this will cause the List ITERATE to end ELSE set %l1 to 0 (zero) which will cause the ITERATE to fire again.

          If you want to discuss this furtheer, emaill me and I will help you thorugh this.

          email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

        • #83727
          Sucharitha Manyala
          Participant

            Thanks for the solution Jim. I used below to split OBX_5 field value and then used your tcl proc in the iterate to get the first element from the list.

            package require textutil

            set obxList [textutil::splitx [lindex $xlateInVals 0] “]

            set outVal

              foreach listVal $obxList {

              lappend outVal ${listVal}

              }

              set outVal [lreplace ${outVal} 0 0]

              set xlateOutVals

        Viewing 1 reply thread
        • The forum ‘Cloverleaf’ is closed to new topics and replies.