Version 8 of eof

Updated 2002-07-26 17:38:51

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 [L1 ] 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?


Tcl syntax help - Arts and crafts of Tcl-Tk programming - Category Command