String Getting Truncated at Space in Output

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf String Getting Truncated at Space in Output

  • Creator
    Topic
  • #52288
    Mark Carey
    Participant

      I’m trying to remove the first 4 characters of an input string in a translate and pass the result to the output string.  I wrote a tcl proc that takes start pos, length and string as parameters.   Here is the tcl proc code.

      proc xltp_substring {} {

         upvar xlateInVals   xlateInVals

       xlateOutVals  xlateOutVals

        set start_pos [lindex $xlateInVals 0]

        set field_length [lindex $xlateInVals 1]

        set str_value [lindex $xlateInVals 2]

        echo xltp_substring start_pos=$start_pos, len=$field_length, string=$str_value

        set xlateOutVals [csubstr $str_value $start_pos $field_length]

      echo $xlateOutVals

      }

      In my case start_pos = 4 and length is 99.  The string passed in is

      ZFA!EASY AUTO

      the echo’s from the code above produces the following from the testing tool.

      xltp_substring start_pos=4, len=99, string=ZFA!EASY AUTO

      EASY AUTO

      But in my output the only thing that gets passed is “EASY”

      0(0).PV1(0).#42(0) “Pending Location” : >EASY< Any ideas? thanks, Mark

    Viewing 2 reply threads
    • Author
      Replies
      • #73702
        Jim Kosloskey
        Participant

          Mark,

          xlateInxxxx and xlateOutxxxx are lists.

          You are treating xlateInVals as a list but you are not treating xlateOutVals as a list.

          Instead of:

          set xlateOutVals [csubstr $str_value $start_pos $field_length]

          do something like this:

          set xlateOutVals [lreplace $xalteOutVals 0 0 [csubstr $str_value $start_pos $field_length]]

          That will insure your data is inserted as a list in XlateOutvals and the space will not act as a list terminator.

          email: jim.kosloskey@jim-kosloskey.com 30+ years Cloverleaf, 60 years IT – old fart.

        • #73703
          Mark Carey
          Participant

            Thanks, that worked well!

            Mark

          • #73704
            Jim Kosloskey
            Participant

              Mark,

              Just remember to always treat the xlateIn… and XlatOut… as lists and you should be good.

              email: jim.kosloskey@jim-kosloskey.com 30+ years Cloverleaf, 60 years IT – old fart.

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