TCL string range command truncates blanks

Homepage Clovertech Forums Read Only Archives Cloverleaf Cloverleaf TCL string range command truncates blanks

  • Creator
    Topic
  • #49726
    Steven Sager
    Participant

    Calling tcl proc in a translation.

    string range “sample string” 3 7

    I should get result “ple s”

    but all I get is “ple”

    Any help? Thanks!

Viewing 6 reply threads
  • Author
    Replies
    • #63299
      John Hamilton
      Participant

      Confused.

      Your code looks correct.

      So I pulled up a tcl comand prompt cut and pasted your command  and it seemed to work correclty.

      clf###@hci – KS_stage: > tcl            

      tcl>string range “sample string” 3 7  

      ple s                                  

      tcl>                                  

    • #63300
      Steven Sager
      Participant

      Yeah, it works interactively.

      I’m having trouble in the translation with tclproc.

      (I’m still working on this.) Have a good one.

    • #63301
      James Cobane
      Participant

      Steve,

      If you are doing this in translation, remember that you need to treat xlateOutVals as a list.  I suspect that you are doing something like:

      set myvar [string range “sample string” 3 7]

      set xlateOutVals $myvar

      where you need to set xlateOutVal as such:

      set xlateOutVals

        The translation is treating the “s” as the second element in xlateOutVals (since there is a space), so it is not getting put into the first output field…..

        Hope this helps.

        Jim Cobane

        Henry Ford Health

    • #63302
      Steven Sager
      Participant

      proc x {} {

      upvar xlateInVals xlateInVals xlateOutVals xlateOutVals

           lassign $xlateInVals data

           set xlateOutVals [string range $data 0 29]

      If my data is contiguous: 123456789012345678901234567890123

      I get a 30 char truncation: 123456789012345678901234567890

      if there are embedded blanks: 123456789 123456789 123456789 123

      I get a truncation after the first blank: 123456789

      (It’s making me more crazier)

    • #63303
      James Cobane
      Participant

      Steve,

      Change:

      set xlateOutVals [string range $data 0 29]

      to:

      set xlateOutVals

        ]

        Jim Cobane

        Henry Ford Health

      1. #63304
        Steven Sager
        Participant

        Mr. Jim Cobane, you have made my day!

        Thank you and may you have a very happy new year!

        – Steve

      2. #63305
        Joseph Benigno
        Participant

        Jim,

        Thank you for your responses to this posting. Solved my problem.

        Your postings contained clear explanation and nice simple examples.

        Now I can end the day on a positive note, feeling like I accomplished something.

        Thanks again

        Joe

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

    Forum Statistics

    Registered Users
    4,966
    Forums
    28
    Topics
    9,104
    Replies
    33,617
    Topic Tags
    248