Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/tcl8.5.2/doc/tell.n @ 35

Last change on this file since 35 was 25, checked in by landauf, 18 years ago

added tcl to libs

File size: 1.6 KB
Line 
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
15tell \- Return current access position for an open channel
16.SH SYNOPSIS
17\fBtell \fIchannelId\fR
18.BE
19
20.SH DESCRIPTION
21.PP
22Returns 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
25that this value is in terms of bytes, not characters like \fBread\fR.
26The value returned is -1 for channels that do not support
27seeking.
28.PP
29\fIChannelId\fR must be an identifier for an open channel such as a
30Tcl standard channel (\fBstdin\fR, \fBstdout\fR, or \fBstderr\fR),
31the return value from an invocation of \fBopen\fR or \fBsocket\fR, or
32the result of a channel creation command provided by a Tcl extension.
33.SH EXAMPLE
34Read 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...
37set offset [\fBtell\fR $chan]
38if {[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"
48file(n), open(n), close(n), gets(n), seek(n), Tcl_StandardChannels(3)
49
50.SH KEYWORDS
51access position, channel, seeking
Note: See TracBrowser for help on using the repository browser.