Just a note on your solution,
Bong. You need to be a bit careful in how you use the
eof command. As it says in the reference page (emphasis added): "Returns 1 if an end of file condition occurred
during the most recent input operation on
channelId (such as
gets), 0 otherwise." In other words,
eof doesn't report the EOF condition unless the EOF was detected on a previous call to
gets or
read. (The same applies to the behavior of the
fblocked command.)
For this reason, when I read files via the
gets command, I prefer the following structure:
Code:
set fid [open $file r]
while {[gets $fid line] != -1} {
# Process the contents of the "line" variable
}
close $fid
- Ken Jones, President, ken@avia-training.com
Avia Training and Consulting,
866-TCL-HELP (866-825-4357) US Toll free
415-643-8692 Voice
415-643-8697 Fax