summaryrefslogtreecommitdiffstats
path: root/doc/seek.n
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2004-10-27 14:23:38 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2004-10-27 14:23:38 (GMT)
commit45beb64f7dcb09a6ce83532702bca760f72e6f4d (patch)
treef7746a2a8316d612570e1456524e3d182e855c82 /doc/seek.n
parent5bc57d7b0f63d86fc383565d69f7704943fff94d (diff)
downloadtcl-45beb64f7dcb09a6ce83532702bca760f72e6f4d.zip
tcl-45beb64f7dcb09a6ce83532702bca760f72e6f4d.tar.gz
tcl-45beb64f7dcb09a6ce83532702bca760f72e6f4d.tar.bz2
Yet more doc update backporting
Diffstat (limited to 'doc/seek.n')
-rw-r--r--doc/seek.n23
1 files changed, 22 insertions, 1 deletions
diff --git a/doc/seek.n b/doc/seek.n
index 5f3118a..efd6ef7 100644
--- a/doc/seek.n
+++ b/doc/seek.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: seek.n,v 1.5 2001/09/14 19:20:40 andreas_kupries Exp $
+'\" RCS: @(#) $Id: seek.n,v 1.5.8.1 2004/10/27 14:23:58 dkf Exp $
'\"
.so man.macros
.TH seek n 8.1 Tcl "Tcl Built-In Commands"
@@ -62,6 +62,27 @@ Note that \fIoffset\fR values are byte offsets, not character
offsets. Both \fBseek\fR and \fBtell\fR operate in terms of bytes,
not characters, unlike \fBread\fR.
.VE 8.1
+.SH EXAMPLES
+Read a file twice:
+.CS
+set f [open file.txt]
+set data1 [read $f]
+\fBseek\fR $f 0
+set data2 [read $f]
+close $f
+# $data1 == $data2 if the file wasn't updated
+.CE
+.PP
+Read the last 10 bytes from a file:
+.CS
+set f [open file.data]
+# This is guaranteed to work with binary data but
+# may fail with other encodings...
+fconfigure $f -translation binary
+\fBseek\fR $f -10 end
+set data [read $f 10]
+close $f
+.CE
.SH "SEE ALSO"
file(n), open(n), close(n), gets(n), tell(n), Tcl_StandardChannels(3)