Re: How to treat puts <value> as pure text - not a command
- From: Bryan Oakley <oakley@xxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 31 Mar 2006 13:52:02 GMT
steve wrote:
Hi Uwe,> switch -glob -- $title {
This is the part doing the reading and writing...
----------------------------------------------------------------------------------
while { [gets $infile in_line] >=0 } {
set open_comment [lsearch -exact $in_line "/*"]
set close_comment [lsearch -exact $in_line "*/"]
...
default
{
puts $outfile "$in_line"
}
}
}
-------------------------------------------------------------------------------------------------------------------------------------------------
I've found that if the $in_line contains an unmatched '{' the script
errors with 'unmatched open brace in list'
The line being processed falls into the 'default' switch
I find it very difficult to believe your code makes it that far. It should choke on the lines where you try to do an lsearch command. Read the man page on lsearch and you'll see it requires a list on input. If your data has unbalanced braces as you say it does, they are decidedly not lists.
The cardinal rule is "never use list commands on strings", which is exactly what you are doing.
Use string first or regexp or something, or use split to convert the string to a list before using list commands.
--
Bryan Oakley
http://www.tclscripting.com
.
- References:
- Prev by Date: Re: newbe q.: How to read windows path names from a file ?
- Next by Date: Re: ANNOUNCE: TIP#262 Published
- Previous by thread: Re: How to treat puts <value> as pure text - not a command
- Next by thread: ANNOUNCE: TIP#262 Published
- Index(es):
Relevant Pages
|