Greytree

TamWiki

For a mouse who is a packrat

Technology » Chomping The Ends Off Of Braced Strings
When args are delivered to a proc in TCL, they might be contained in braces. Here's how to deal with that.

Summary:this is what goes at the top of the site

(redirected from Main.ChompingTheEndsOffOfBracedStrings)

Up: ^TclTk^

I noticed that when there is nothing passed in an args paramter (a catch-all parameter that sucks up the rest of the parameters in a proc call), it contains the string "{}". This is an actual string, not a braced expression. To get rid of those, and to be able to treat args as a regular string, the following seems to work:

  [string range $args 1 [expr {[string length $args]-2}]]

This removes the first character and last character from the string (strings are basically zero-based).


Tags: Categories: Articles

Recent Changes | Printable View | Page History | Edit Page
Page last modified on April 09, 2012, at 09:27 AM by tamara