1tell(n)                      Tcl Built-In Commands                     tell(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       tell - Return current access position for an open channel
9

SYNOPSIS

11       tell channelId
12______________________________________________________________________________
13

DESCRIPTION

15       Returns  an  integer string giving the current access position in chan‐
16       nelId.  This value returned is a byte offset that can be passed to seek
17       in  order  to set the channel to a particular position.  Note that this
18       value is in terms of  bytes,  not  characters  like  read.   The  value
19       returned is -1 for channels that do not support seeking.
20
21       ChannelId must be an identifier for an open channel such as a Tcl stan‐
22       dard channel (stdin, stdout, or stderr), the return value from an invo‐
23       cation  of  open or socket, or the result of a channel creation command
24       provided by a Tcl extension.
25

EXAMPLE

27       Read a line from a file channel only if it starts with foobar:
28
29              # Save the offset in case we need to undo the read...
30              set offset [tell $chan]
31              if {[read $chan 6] eq "foobar"} {
32                  gets $chan line
33              } else {
34                  set line {}
35                  # Undo the read...
36                  seek $chan $offset
37              }
38

SEE ALSO

40       file(n), open(n), close(n), gets(n), seek(n), Tcl_StandardChannels(3)
41

KEYWORDS

43       access position, channel, seeking
44
45
46
47Tcl                                   8.1                              tell(n)
Impressum