Tcl string escape
Heyhoo,
now i need to compare a String like "[INTENSITY]" to $line. ATM i want to do it like
if { [string compare "[INTENSITY]" $line] == 0 } { }
but i think there is a problem with the "[" and the "]". But how could i escape it ? I could not find a good book or a really good website online.
Next Questio开发者_StackOverflow中文版n is i created an array like
set data [split $file_data "\n"]
why i coulnd say array stat $data
???
Hope you could help me again.
For the first item, use {}
as string delimiters to prevent command substitution (which is what happens with [] in a double-quoted string)
if { [string compare {[INTENSITY]} $line] == 0 } { }
On the second item, split
creates a list, not an array. Index into it with lindex
:
set data [split $file_data "\n"]
puts [lindex $data 1]
The best website for tcl info is the Tcler's Wiki at http://wiki.tcl.tk/
精彩评论