seek(n) Tcl Built-In Commands seek(n) NAME seek - Change the access(2,5) position for an open(2,3,n) channel SYNOPSIS seek channelId offset ?origin? DESCRIPTION Changes the current access(2,5) position for channelId. ChannelId must be an identifier for an open(2,3,n) channel such as a Tcl stan- dard channel (stdin, stdout, or stderr), the return value from an invo- cation of open(2,3,n) or socket(2,7,n), or the result of a channel creation command provided by a Tcl extension. The offset and origin arguments specify the position at which the next read(2,n,1 builtins) or write(1,2) will occur for channelId. Offset must be an integer (which may be negative) and origin must be one of the following: start The new access(2,5) position will be offset bytes from the start of the underlying file(1,n) or device. current The new access(2,5) position will be offset bytes from the current access(2,5) position; a negative offset moves the access(2,5) position backwards in(1,8) the underlying file(1,n) or device. end The new access(2,5) position will be offset bytes from the end of the file(1,n) or device. A negative offset places the access(2,5) position before the end of file(1,n), and a positive offset places the access(2,5) position after the end of file. The origin argument defaults to start. The command flushes all buffered output for the channel before the com- mand returns, even if(3,n) the channel is in(1,8) nonblocking mode. It also dis- cards any buffered and unread input. This command returns an empty string. An error(8,n) occurs if(3,n) this command is applied to channels whose underlying file(1,n) or device does not support seeking. Note that offset values are byte offsets, not character offsets. Both seek and tell operate in(1,8) terms of bytes, not characters, unlike read(2,n,1 builtins). SEE ALSO file(1,n)(n), open(2,3,n)(n), close(2,7,n)(n), gets(3,n)(n), tell(n), Tcl_StandardChannels(3) KEYWORDS access(2,5) position, file(1,n), seek Tcl 8.1 seek(n)