summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2004-04-16 10:28:54 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2004-04-16 10:28:54 (GMT)
commit0edcd84dd859277b50c6666a4d90101a67c76746 (patch)
treeb8531294268ac821a86ec0ff6899c6b714fad64a
parente9c2be75488623a37e950be08766ed339938da0c (diff)
downloadtcl-0edcd84dd859277b50c6666a4d90101a67c76746.zip
tcl-0edcd84dd859277b50c6666a4d90101a67c76746.tar.gz
tcl-0edcd84dd859277b50c6666a4d90101a67c76746.tar.bz2
Added example based on [Patch 935911] from David Welton.
-rw-r--r--ChangeLog4
-rw-r--r--doc/gets.n15
2 files changed, 18 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 6fed1b5..2e438e9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2004-04-16 Donal K. Fellows <donal.k.fellows@man.ac.uk>
+
+ * doc/gets.n: Added example based on [Patch 935911].
+
2004-04-15 Donal K. Fellows <donal.k.fellows@man.ac.uk>
* generic/tclClock.c (Tcl_ClockObjCmd): Minor fault in a [clock
diff --git a/doc/gets.n b/doc/gets.n
index f884d11..8631e4b 100644
--- a/doc/gets.n
+++ b/doc/gets.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: gets.n,v 1.4 2001/09/14 19:20:40 andreas_kupries Exp $
+'\" RCS: @(#) $Id: gets.n,v 1.5 2004/04/16 10:28:55 dkf Exp $
'\"
.so man.macros
.TH gets n 7.5 Tcl "Tcl Built-In Commands"
@@ -52,6 +52,19 @@ only of the end-of-line character(s).
The \fBeof\fR and \fBfblocked\fR commands can be used to distinguish
these three cases.
+.SH "EXAMPLE"
+This example reads a file one line at a time and prints it out with
+the current line number attached to the start of each line.
+
+.CS
+set chan [open "some.file.txt"]
+set lineNumber 0
+while {[gets $chan line] >= 0} {
+ puts "[incr lineNumber]: $line"
+}
+close $chan
+.CE
+
.SH "SEE ALSO"
file(n), eof(n), fblocked(n), Tcl_StandardChannels(3)