split command:
Closed / Invalid785392ffffffffffffffffffffffffffffffffffCreated 23 years agoUpdated 23 years ago
Descriptionplain2003-08-08 13:46:35
Bug desciption:
If a text string contains a { or } sign and you want to
split on the "{" or "}" characters the bug occures.
proc bug {} {
Text "hello how are you { see you}"
msglines [split $text "{" ] {
set msgline($linenumber) $msglines
incr linenumber 1}
for {set f 0} {$f <$linenumber} {incr f 1} {
puts $config $msgline($f);puts $config $f}
}
this give a compile error :
Extra character after close brace. but this is not true..
It has nothing to do with the proc. it is part of a string
and should not be recognized as a part of the procedure
dgpplain2003-08-08 22:28:24
Logged In: YES
user_id=80530
Your example script has one command, [proc].
Its first argument is "bug"
Its second argument is "" (empty string)
To determine the third argument, the parser
sees that it is quoted with a leading "{" so it
starts scanning the text for the matching "}"
that marks the end of the word.
0
{
1 1
Text "hello how are you { see you}"
1 2
msglines [split $text "{" ] {
set msgline($linenumber) $msglines
2
incr linenumber 1}
2 2 2 2 2 2 2
for {set f 0} {$f <$linenumber} {incr f 1} {
2
puts $config $msgline($f);puts $config $f}
1
}
...and your script ends without providing the
closing "}" to end the third argument.
The correct fix is to use backslash-quoting to
mark those "{" and "}" characters that the parser
should not count. So change the [split] line above
to
msglines [split $text \{ ] {
Log in (anonymous is fine) to add a comment.