TCL string range command —WHAT IF SCENARIO

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf TCL string range command —WHAT IF SCENARIO

  • Creator
    Topic
  • #49335
    Duy Nguyen
    Participant

      If I were to use the string range command and specified 0 and 2 as my first and last range of characters to pull, what would happen if the string was less than 3 characters?  

      I am basically wanting to compare only the first 3 characters of a variable/field.  Would the string range command be best suited for something like this?  I’m open to suggestions.  Thanks.

    Viewing 2 reply threads
    • Author
      Replies
      • #61554
        Vincent Tran
        Participant

          Hm, from reading this http://wiki.tcl.tk/10168” class=”bbcode_url”>http://wiki.tcl.tk/10168

          It says

          Quote:

          if last is greater than or equal to the length of the string then it is treated as if it were end.

          So if you had a string less than three characters like “ab”, then it would return “ab”

        • #61555
          Duy Nguyen
          Participant

            thank you, sir.

          • #61556
            Russ Ross
            Participant

              FYI:  you can run hcitcl interactively at the command prompt on your cloverleaf server, which is very useful for answering these types of questions.

              Attached is a sceen shot illustrating my interactive session with hcitcl that I used to perform a simple test to see how it behaves for the question you posted.

              Russ Ross
              RussRoss318@gmail.com

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