Seek

(Engine-Level Function)

Description: Changes and returns the current position within a stream. The return value is the current stream position after the seek is done.
Returns: Numeric
Usage: Script Only.
Function Groups: Stream and Socket
Related to: BuffStream | CloseStream | FileStream | GetStreamLength | SRead | StreamEnd | SWrite
Format: Seek(Stream, Position[, Mode])
Parameters:  
Stream
Required. Any expression that returns the stream to do the Seek on
Position
Required. Any numeric expression that returns either the absolute position, or a relative amount to move the position, depending on Mode. If the mode is relative, this number may be negative (i.e. earlier in the stream).
Mode
An optional numeric expression that denotes which type of positioning to do. If equal to 0, the stream position is changed to Position (absolute mode). If equal to 1, the Position is added to the current stream position (relative mode ). Defaults to 0.
Comments: This allows repositioning within a stream.
This function can be used to find the current stream position by setting the last two parameters to "0,1".

Example:

If ! Valid(strm);
[
  strm = BuffStream("ABCDEF");
  Seek(strm, 3, 0);
  SRead(strm, "%1c", streamData);
]

The variable streamData now contains the string "D".