.SEEK streamnumber offset
(.SEEK streamnumber offset mode)
.SEEK positions the read/write pointer of the specified stream to the numerical byte position given as its second input. The output of the .SEEK command is the current stream position. Note that it is possible to position beyond the end of a file.
If .SEEK is supplied with an optional third input, this input affects the way the pointer is positioned:
0 Position = offset; equivalent to .SEEK streamnumber offset
1 Position = Current position + offset
2 Position = End-of-file + offset
Using .SEEK with the stream number only as input yields the current position of the stream pointer.
The following example opens a file for reading and writing, seeks to position 32 and writes the letter "X at that position.
TO WRITE.X.AT.32 :NAME
- MAKE "STREAM (OPEN :NAME "RW)
- MAKE "DATA BYTEARRAY 1
- ASET :DATA 0 #H58
- .SEEK :STREAM 32
- .WRITE :STREAM :DATA 1
- CLOSE :STREAM