Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/tcl8.5.2/doc/eof.n @ 25

Last change on this file since 25 was 25, checked in by landauf, 16 years ago

added tcl to libs

File size: 1.6 KB
Line 
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'\" RCS: @(#) $Id: eof.n,v 1.9 2007/12/13 15:22:32 dgp Exp $
9'\"
10.so man.macros
11.TH eof n 7.5 Tcl "Tcl Built-In Commands"
12.BS
13'\" Note:  do not modify the .SH NAME line immediately below!
14.SH NAME
15eof \- Check for end of file condition on channel
16.SH SYNOPSIS
17\fBeof \fIchannelId\fR
18.BE
19
20.SH DESCRIPTION
21.PP
22Returns 1 if an end of file condition occurred during the most
23recent input operation on \fIchannelId\fR (such as \fBgets\fR),
240 otherwise.
25.PP
26\fIChannelId\fR must be an identifier for an open channel such as a
27Tcl standard channel (\fBstdin\fR, \fBstdout\fR, or \fBstderr\fR),
28the return value from an invocation of \fBopen\fR or \fBsocket\fR, or
29the result of a channel creation command provided by a Tcl extension.
30.SH EXAMPLES
31Read and print out the contents of a file line-by-line:
32.CS
33set f [open somefile.txt]
34while {1} {
35    set line [gets $f]
36    if {[\fBeof\fR $f]} {
37        close $f
38        break
39    }
40    puts "Read line: $line"
41}
42.CE
43.PP
44Read and print out the contents of a file by fixed-size records:
45.CS
46set f [open somefile.dat]
47fconfigure $f -translation binary
48set recordSize 40
49while {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
59.SH "SEE ALSO"
60file(n), open(n), close(n), fblocked(n), Tcl_StandardChannels(3)
61
62.SH KEYWORDS
63channel, end of file
Note: See TracBrowser for help on using the repository browser.