1mNAME0m
       seek - Change the access position for an open channel

1mSYNOPSIS0m
       1mseek 4m22mchannelId24m 4moffset24m ?4morigin24m?


1mDESCRIPTION0m
       Changes the current access position for 4mchannelId24m.

       4mChannelId24m must be an identifier for an open channel such as a Tcl stan-
       dard channel (1mstdin22m, 1mstdout22m, or 1mstderr22m), the return value from an invo-
       cation  of  1mopen 22mor 1msocket22m, or the result of a channel creation command
       provided by a Tcl extension.

       The 4moffset24m and 4morigin24m arguments specify the position at which the  next
       read  or  write  will  occur  for  4mchannelId24m. 4mOffset24m must be an integer
       (which may be negative) and 4morigin24m must be one of the following:

       1mstart     22mThe new access position will be 4moffset24m bytes from  the  start
                 of the underlying file or device.

       1mcurrent   22mThe new access position will be 4moffset24m bytes from the current
                 access position; a negative 4moffset24m moves the access  position
                 backwards in the underlying file or device.

       1mend       22mThe  new access position will be 4moffset24m bytes from the end of
                 the file or device.  A  negative  4moffset24m  places  the  access
                 position before the end of file, and a positive 4moffset24m places
                 the access position after the end of file.

       The 4morigin24m argument defaults to 1mstart22m.

       The command flushes all buffered output for the channel before the com-
       mand returns, even if the channel is in nonblocking mode.  It also dis-
       cards any buffered and unread input.  This  command  returns  an  empty
       string.   An  error occurs if this command is applied to channels whose
       underlying file or device does not support seeking.

       Note that 4moffset24m values are byte offsets, not character offsets.   Both
       1mseek 22mand 1mtell 22moperate in terms of bytes, not characters, unlike 1mread22m.

1mEXAMPLES0m
       Read a file twice:
              set f [open file.txt]
              set data1 [read $f]
              1mseek 22m$f 0
              set data2 [read $f]
              close $f
              # $data1 == $data2 if the file wasn't updated

       Read the last 10 bytes from a file:
              set f [open file.data]
              # This is guaranteed to work with binary data but
              # may fail with other encodings...
              fconfigure $f -translation binary
              1mseek 22m$f -10 end
              set data [read $f 10]
              close $f


1mSEE ALSO0m
       file(n), open(n), close(n), gets(n), tell(n), Tcl_StandardChannels(3)


1mKEYWORDS0m
