Version 4 of eof

Updated 2002-06-26 11:36:23

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:

 while {[gets $fp line]>=0} {...}

instead of

 while {![eof $fp]} {
    gets $fp line
    if [eof $fp break] ;# otherwise loops one time too many
    ...
 } ;# RS  

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