1eof(n) Tcl Built-In Commands eof(n)
2
3
4
5______________________________________________________________________________
6
8 eof - Check for end of file condition on channel
9
11 eof channelId
12_________________________________________________________________
13
14
16 Returns 1 if an end of file condition occurred during the most recent
17 input operation on channelId (such as gets), 0 otherwise.
18
19 ChannelId must be an identifier for an open channel such as a Tcl stan‐
20 dard channel (stdin, stdout, or stderr), the return value from an invo‐
21 cation of open or socket, or the result of a channel creation command
22 provided by a Tcl extension.
23
25 Read and print out the contents of a file line-by-line:
26 set f [open somefile.txt]
27 while {1} {
28 set line [gets $f]
29 if {[eof $f]} {
30 close $f
31 break
32 }
33 puts "Read line: $line"
34 }
35
36 Read and print out the contents of a file by fixed-size records:
37 set f [open somefile.dat]
38 fconfigure $f -translation binary
39 set recordSize 40
40 while {1} {
41 set record [read $f $recordSize]
42 if {[eof $f]} {
43 close $f
44 break
45 }
46 puts "Read record: $record"
47 }
48
49
51 file(n), open(n), close(n), fblocked(n), Tcl_StandardChannels(3)
52
53
55 channel, end of file
56
57
58
59Tcl 7.5 eof(n)