Debian Codegraph @

doc/eof.n

raw
1 '\"
2 '\" Copyright (c) 1993 The Regents of the University of California.
3 '\" Copyright (c) 1994-1996 Sun Microsystems, Inc.
4 '\"
5 '\" See the file "license.terms" for information on usage and redistribution
6 '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
7 '\"
8 .TH eof n 7.5 Tcl "Tcl Built-In Commands"
9 .so man.macros
10 .BS
11 '\" Note: do not modify the .SH NAME line immediately below!
12 .SH NAME
13 eof \- Check for end of file condition on channel
14 .SH SYNOPSIS
15 \fBeof \fIchannelId\fR
16 .BE
17 .SH DESCRIPTION
18 .PP
19 Returns 1 if an end of file condition occurred during the most
20 recent input operation on \fIchannelId\fR (such as \fBgets\fR),
21 0 otherwise.
22 .PP
23 \fIChannelId\fR must be an identifier for an open channel such as a
24 Tcl standard channel (\fBstdin\fR, \fBstdout\fR, or \fBstderr\fR),
25 the return value from an invocation of \fBopen\fR or \fBsocket\fR, or
26 the result of a channel creation command provided by a Tcl extension.
27 .SH EXAMPLES
28 .PP
29 Read and print out the contents of a file line-by-line:
30 .PP
31 .CS
32 set f [open somefile.txt]
33 while {1} {
34 set line [gets $f]
35 if {[\fBeof\fR $f]} {
36 close $f
37 break
38 }
39 puts "Read line: $line"
40 }
41 .CE
42 .PP
43 Read and print out the contents of a file by fixed-size records:
44 .PP
45 .CS
46 set f [open somefile.dat]
47 fconfigure $f -translation binary
48 set recordSize 40
49 while {1} {
50 set record [read $f $recordSize]
51 if {[\fBeof\fR $f]} {
52 close $f
53 break
54 }
55 puts "Read record: $record"
56 }
57 .CE
58 .SH "SEE ALSO"
59 file(n), open(n), close(n), fblocked(n), Tcl_StandardChannels(3)
60 .SH KEYWORDS
61 channel, end of file