tell.n
上传用户:rrhhcc
上传日期:2015-12-11
资源大小:54129k
文件大小:2k
- '"
- '" 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
- .TH tell n 8.1 Tcl "Tcl Built-In Commands"
- .BS
- '" Note: do not modify the .SH NAME line immediately below!
- .SH NAME
- tell - Return current access position for an open channel
- .SH SYNOPSIS
- fBtell fIchannelIdfR
- .BE
- .SH DESCRIPTION
- .PP
- .VS 8.1
- Returns an integer string giving the current access position in
- fIchannelIdfR. This value returned is a byte offset that can be passed to
- fBseekfR in order to set the channel to a particular position. Note
- that this value is in terms of bytes, not characters like fBreadfR.
- .VE 8.1
- The value returned is -1 for channels that do not support
- seeking.
- .PP
- .VS
- fIChannelIdfR must be an identifier for an open channel such as a
- Tcl standard channel (fBstdinfR, fBstdoutfR, or fBstderrfR),
- the return value from an invocation of fBopenfR or fBsocketfR, or
- the result of a channel creation command provided by a Tcl extension.
- .VE
- .SH EXAMPLE
- Read a line from a file channel only if it starts with fBfoobarfR:
- .CS
- # Save the offset in case we need to undo the read...
- set offset [fBtellfR $chan]
- if {[read $chan 6] eq "foobar"} {
- gets $chan line
- } else {
- set line {}
- # Undo the read...
- seek $chan $offset
- }
- .CE
- .SH "SEE ALSO"
- file(n), open(n), close(n), gets(n), seek(n), Tcl_StandardChannels(3)
- .SH KEYWORDS
- access position, channel, seeking