Version 4 of seek

Updated 2003-07-08 16:05:50

http://www.purl.org/tcl/home/man/tcl8.4/TclCmd/seek.htm

Example (no error handling done here - be sure to do some in real life!) :

 % cat /tmp/mydata
 1234567890abcdefghijklmnopqrstuvwxyz
 % set f [open "/tmp/mydata" "r+"]
 file3
 % seek $f 20
 % puts -nonewline $f "KLM"
 % close $f
 % cat /tmp/mydata
 1234567890abcdefghijKLMnopqrstuvwxyz


Is there supposed to be a difference in the seek/puts behavior based on varying the open access value between "r+, "w+" and "a+"?


One interesting use for seek is to constrain the size of output files. [...]


Tcl syntax help - Arts and crafts of Tcl-Tk programming - Category Command