summaryrefslogtreecommitdiffstats
path: root/doc/eof.n
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2004-10-27 09:35:37 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2004-10-27 09:35:37 (GMT)
commit7ea5d4dbe8b82a86701cec95132a8a9557a5f105 (patch)
tree2f3f979845a50074bb8e2a0687cd98cb14ae6c26 /doc/eof.n
parenta50314f88b2a6af554553927c9c0e590c0acf7dc (diff)
downloadtcl-7ea5d4dbe8b82a86701cec95132a8a9557a5f105.zip
tcl-7ea5d4dbe8b82a86701cec95132a8a9557a5f105.tar.gz
tcl-7ea5d4dbe8b82a86701cec95132a8a9557a5f105.tar.bz2
Backport many doc fixes
Diffstat (limited to 'doc/eof.n')
-rw-r--r--doc/eof.n32
1 files changed, 29 insertions, 3 deletions
diff --git a/doc/eof.n b/doc/eof.n
index ad5f90f..ed93dff 100644
--- a/doc/eof.n
+++ b/doc/eof.n
@@ -5,7 +5,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" RCS: @(#) $Id: eof.n,v 1.4 2001/09/14 19:20:40 andreas_kupries Exp $
+'\" RCS: @(#) $Id: eof.n,v 1.4.8.1 2004/10/27 09:35:38 dkf Exp $
'\"
.so man.macros
.TH eof n 7.5 Tcl "Tcl Built-In Commands"
@@ -23,12 +23,38 @@ Returns 1 if an end of file condition occurred during the most
recent input operation on \fIchannelId\fR (such as \fBgets\fR),
0 otherwise.
.PP
-.VS
\fIChannelId\fR must be an identifier for an open channel such as a
Tcl standard channel (\fBstdin\fR, \fBstdout\fR, or \fBstderr\fR),
the return value from an invocation of \fBopen\fR or \fBsocket\fR, or
the result of a channel creation command provided by a Tcl extension.
-.VE
+.SH EXAMPLES
+Read and print out the contents of a file line-by-line:
+.CS
+set f [open somefile.txt]
+while {1} {
+ set line [gets $f]
+ if {[\fBeof\fR $f]} {
+ close $f
+ break
+ }
+ puts "Read line: $line"
+}
+.CE
+.PP
+Read and print out the contents of a file by fixed-size records:
+.CS
+set f [open somefile.dat]
+fconfigure $f -translation binary
+set recordSize 40
+while {1} {
+ set record [read $f $recordSize]
+ if {[\fBeof\fR $f]} {
+ close $f
+ break
+ }
+ puts "Read record: $record"
+}
+.CE
.SH "SEE ALSO"
file(n), open(n), close(n), fblocked(n), Tcl_StandardChannels(3)