Hi,
I have a tcl library procedure that reads a log entry from a log
file. The log entry is appended to a variable of type string. When
the procedure has completed reading the file, it returns the
variable.
ad_proc get_chunk { } { } {
set filename "/some/file"
set file [open $filename "r"]
set out ""
while { [gets $file line] >= 0 } {
append out $line
append out "
"
if { [string length $out] >= 8192 } {
ns_write $out
set out ""
}
}
close $file
return $out
}
From another tcl file, when I call this method, I want to read each
line and process it in a loop. Do I use the tcl gets command? eg
while { [gets get_chunk line] >= 0 } {
#process line
}
Or am I suppose to open a stream or channel somehow?