1eof(n)                       Tcl Built-In Commands                      eof(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       eof - Check for end of file condition on channel
9

SYNOPSIS

11       eof channelId
12______________________________________________________________________________
13

DESCRIPTION

15       Returns  1  if an end of file condition occurred during the most recent
16       input operation on channelId (such as gets), 0 otherwise.
17
18       ChannelId must be an identifier for an open channel such as a Tcl stan‐
19       dard channel (stdin, stdout, or stderr), the return value from an invo‐
20       cation of open or socket, or the result of a channel  creation  command
21       provided by a Tcl extension.
22

EXAMPLES

24       Read and print out the contents of a file line-by-line:
25
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
38              set f [open somefile.dat]
39              fconfigure $f -translation binary
40              set recordSize 40
41              while {1} {
42                  set record [read $f $recordSize]
43                  if {[eof $f]} {
44                      close $f
45                      break
46                  }
47                  puts "Read record: $record"
48              }
49

SEE ALSO

51       file(n), open(n), close(n), fblocked(n), Tcl_StandardChannels(3)
52

KEYWORDS

54       channel, end of file
55
56
57
58Tcl                                   7.5                               eof(n)
Impressum