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: tell.n,v 1.9 2005/05/10 18:34:03 kennykb Exp $ |
---|
9 | '\" |
---|
10 | .so man.macros |
---|
11 | .TH tell n 8.1 Tcl "Tcl Built-In Commands" |
---|
12 | .BS |
---|
13 | '\" Note: do not modify the .SH NAME line immediately below! |
---|
14 | .SH NAME |
---|
15 | tell \- Return current access position for an open channel |
---|
16 | .SH SYNOPSIS |
---|
17 | \fBtell \fIchannelId\fR |
---|
18 | .BE |
---|
19 | |
---|
20 | .SH DESCRIPTION |
---|
21 | .PP |
---|
22 | Returns an integer string giving the current access position in |
---|
23 | \fIchannelId\fR. This value returned is a byte offset that can be passed to |
---|
24 | \fBseek\fR in order to set the channel to a particular position. Note |
---|
25 | that this value is in terms of bytes, not characters like \fBread\fR. |
---|
26 | The value returned is -1 for channels that do not support |
---|
27 | seeking. |
---|
28 | .PP |
---|
29 | \fIChannelId\fR must be an identifier for an open channel such as a |
---|
30 | Tcl standard channel (\fBstdin\fR, \fBstdout\fR, or \fBstderr\fR), |
---|
31 | the return value from an invocation of \fBopen\fR or \fBsocket\fR, or |
---|
32 | the result of a channel creation command provided by a Tcl extension. |
---|
33 | .SH EXAMPLE |
---|
34 | Read a line from a file channel only if it starts with \fBfoobar\fR: |
---|
35 | .CS |
---|
36 | # Save the offset in case we need to undo the read... |
---|
37 | set offset [\fBtell\fR $chan] |
---|
38 | if {[read $chan 6] eq "foobar"} { |
---|
39 | gets $chan line |
---|
40 | } else { |
---|
41 | set line {} |
---|
42 | # Undo the read... |
---|
43 | seek $chan $offset |
---|
44 | } |
---|
45 | .CE |
---|
46 | |
---|
47 | .SH "SEE ALSO" |
---|
48 | file(n), open(n), close(n), gets(n), seek(n), Tcl_StandardChannels(3) |
---|
49 | |
---|
50 | .SH KEYWORDS |
---|
51 | access position, channel, seeking |
---|