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