12.5.34.1    seek

Description:   Change the access position for an open channels and files.

 

Syntax:         seek channelId offset ?origin?

         

Argument:     option, IO channel

Returns:         

 

See Also:       puts, file, gets, open

 

Examples:      # Example 1

# Report1 is a Text File used for report data

     set fileid [open "../ReportClient2.txt" a+]

     seek $fileid 0 start

     puts $fileid "----- Water Use Report-------\nPage 1"

 # Insert data into table

     puts $fileid "[GETVAL %TTMDATE]  [GETVAL %TTMTIME]  [GETVAL AMPLITUDE]  [GETVAL TIMER] "

     close $fileid

Changes the current access position for channelId. ChannelId must be a channel identifier such as returned from a previous invocation of open or socket. The offset and origin arguments specify the position at which the next read or write 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 position will be offset bytes from the start of the underlying file or device.

current The new access position will be offset bytes from the current access position; a negative offset moves the access position backwards in the underlying file or device.

end       The new access position will be offset bytes from the end of the file or device. A negative offset places the access position before the end of file, and a positive offset places the access position after the end of file.

The if no origin specified, command uses default start.

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.