Need to work with a list like it’s a string

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Need to work with a list like it’s a string

  • Creator
    Topic
  • #55753
    Vince Angulo
    Participant

      It’s been a while since I’ve had to do something like this, and it’s just not jelling — I’m sure I’m making a basic, “it’s a list thing” mistake.

      Here’s what I need to do:  take a free-text phrase that may contain spaces, force it toupper (not a problem), then truncate it to 12 characters.  For example,

      Input:

      Output:

      Just can’t remember how to have Tcl consider xlateInVals as a string, not a list without getting an XPM Tcl Error.

      Can anyone get me on the right track?  Or can this be elegantly done in a translate at all, or do I need to brute force it in a proc?

      Thanks in advance!!!!

    Viewing 4 reply threads
    • Author
      Replies
      • #86399
        Keith McLeod
        Participant

          You might try something like this:

          set xlateOutVals

            0 11]]

            example:

            hcitcl>set xlateInVals

          1. Something Like This

            hcitcl>set xlateOutVals

              0 11]]

              {SOMETHING LI}

              hcitcl>

        • #86400
          Vince Angulo
          Participant

            Thanks Keith!!!

            I’ll try that — it’s looks awfully familiar, and as usual, I was making this way too hard in my head….

          • #86401
            Vince Angulo
            Participant

              Much closer thanks to Keith!

              I don’t get the error, but

              set xlateOutVals

                0 11]]

                returns the leading brace as part of the string range result:

                |{SOMETHING L|

              1. #86402
                Mary Kobis
                Participant

                  replace $xlateInVals with [lindex $xlateInVals 0]. I have found the { disappears when you do this, even though there is only 1 value.

                • #86403
                  Vince Angulo
                  Participant

                    That did it Mary!!

                    Thanks  ðŸ˜€  ðŸ˜€  ðŸ˜€  ðŸ˜€

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