Re: How to treat puts <value> as pure text - not a command



Hi Uwe,
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 "*/"]

if {$open_comment != -1} {
set comment_flag 1
}
if {!$comment_flag} {
set title [lindex [split $in_line :] 0] ; #split line at :
set text [lindex [split $in_line :] 1]

switch -glob -- $title {
"TMS ID" {
puts $error_log "writing out TMS ID..."
gets $template out_line
set temp_title [lindex [split $out_line :] 0]
set out_line [concat $temp_title : $text]
puts $outfile $out_line
}
"Test Title" {
puts $error_log "writing out Title..."
gets $template out_line
puts $error_log "Read from template $out_line"
set temp_title [lindex [split $out_line :] 0]
puts $error_log "temp title...$temp_title"
set out_line [concat $temp_title : $text]
puts $outfile $out_line
}
"Reference(s)" {
puts $error_log "Adding Livelink No. $livelink"
puts $error_log "Adding Test Case udoc mr $udoc_mr "
puts $outfile $in_line
puts $outfile "Test Plan Livelink Number $livelink."
puts $outfile "Test Case udoc mr $udoc_mr. "
}
"Dependances" {
puts $error_log "removing dependances as not required..."
}
"Included Test I.D" {
puts $error_log "removing included test id as not required..."
}
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

.



Relevant Pages

  • Re: Bug in teapot?
    ... It is not elegant, and I have not had a chance to do extensive testing, but it should create a semi-equivalent file to what teacup was intended to create. ... puts "Opening files ..." ... set outFile ... This file contains invalid tcl code, which remainds me of bad substitutions with regular expresions or string map :-) ...
    (comp.lang.tcl)
  • Re: How to write output of a tcl script to a file?
    ... File I/O in Tcl, that'd be best. ...    files on disk or sockets or the console or ... ... (puts and gets also take an implicit ... puts $outfile ...
    (comp.lang.tcl)
  • Re: When will Teacup be usable again ?
    ... It's not perfect but you can use the packages that are installed by teapot. ... From my understanding there will be a new command to rebuild the original pkgIndex.tcl file. ... puts "Opening files ..." ... set outFile ...
    (comp.lang.tcl)
  • Re: Bug in teapot?
    ... George Peter Staplin wrote: ... proc main {argc argv} { ... puts "Opening files ..." ... set outFile ...
    (comp.lang.tcl)
  • Re: Bug in teapot?
    ... proc main {argc argv} { ... file rename pkgIndex.tcl pkgIndex_$i.tcl ... puts "Opening files ..." ... set outFile ...
    (comp.lang.tcl)