Copyright (c) 1993 The Regents of the University of California.
Copyright (c) 1994-1996 Sun Microsystems, Inc.
See the file "license.terms" for information on usage and redistribution
of this file, and for a DISCLAIMER OF ALL WARRANTIES.
RCS: @(#) $Id: tell.n,v 1.5.8.1 2004/10/27 14:43:14 dkf Exp $
.so man.macros
tell n 8.1 Tcl "Tcl Built-In Commands"
S Note: do not modify the .SH NAME line immediately below! NAME
tell - Return current access position for an open channel
SYNOPSIS
tell channelId
E
DESCRIPTION
.VS 8.1 Returns an integer string giving the current access position in channelId. This value returned is a byte offset that can be passed to seek in order to set the channel to a particular position. Note that this value is in terms of bytes, not characters like read. .VE 8.1 The value returned is -1 for channels that do not support seeking.
.VS ChannelId must be an identifier for an open channel such as a Tcl standard channel (stdin, stdout, or stderr), the return value from an invocation of open or socket, or the result of a channel creation command provided by a Tcl extension. .VE
EXAMPLE
Read a line from a file channel only if it starts with foobar:
.CS
# Save the offset in case we need to undo the read...
set offset [tell $chan]
if {[read $chan 6] eq "foobar"} {
gets $chan line
} else {
set line {}
# Undo the read...
seek $chan $offset
}
.CE
"SEE ALSO"
file(n), open(n), close(n), gets(n), seek(n), Tcl_StandardChannels(3)
KEYWORDS
access position, channel, seeking