eof is, in one sense, a command: http://purl.org/tcl/home/man/tcl8.4/TclCmd/eof.htm and, in another sense, an acronym for ''End Of File''. ---- Programmers can use eof to determine whether the channel has reached the end of input. Note that it fires only after the last successful [gets], so testing for a -1 return value on gets may be a better idea, and avoid eof's [FMM] [http://phaseit.net/claird/comp.lang.tcl/fmm.html#eof] by coding: while {[gets $fp line]>=0} {...} instead of while {![eof $fp]} { gets $fp line if [eof $fp break] ;# otherwise loops one time too many ... } ;# RS ---- Hmmm... the only thing I find eof good for is as a condition which should trigger closing a socket. That is, if you are trying to read a non-blocking socket and you hit eof, you KNOW that it's time to close the socket. '''-PSE''' ---- Can anyone indicate whether there are certain types of channels (pipe, socket, etc.) where eof doesn't do what one might at first blush expect? [JMN] 2003-07-15 This isn't directly referring to the eof command - but is an EOF issue that I wasn't expecting so here looks as good a place as any to mention it. Using the Memchan package, I was trying to fcopy from a memchan to a file roughly like so: set m [memchan] puts $m "someStringData" seek $m 0 start fcopy $m $fd -command CopyFinished proc CopyFinished args { ... } This performed the copy to file just fine, but the CopyFinished proc never got called. To fix this, I called fconfigure $m -eofchar {} before the puts line.. and fconfigure $m -eofchar \x1a before the fcopy line. Then I changed the puts line to: puts $m "someStringData\x1a" This seems like a bit of hoop-jumping to get the expected fcopy behaviour.. am I missing something simple? ---- [Tcl syntax help] - [Arts and crafts of Tcl-Tk programming] - [Category Command]