Storages & Files Seek
Seek method

Implements navigation through the stream (more extended than the functionality supplied by the Pos property)

Syntax:

variable = object.Seek( position, origin)

Parameters:

position - positive or negative numeric value - the position to navigate to

origin - a constant, specifies how to calculate the physical position over the supplied position parameter. The constants are:

Value Constant Description
0 cStreamBegin Position must be positive and specifies the stream position (in bytes) calculated from the beginning of the stream. 
1 cStreamCurrent Position can be positive or negative. The stream position is moved forward (positive) or backwards (negative) from the current stream position. 
2 cStreamEnd Calculated from the end of stream. Positive values will enlarge the stream size. 

returned value: The resulting absolute position of the stream. 

Examples:

Set sf = Server.CreateObject("newObjects.utilctls.SFMain")
Set file = sf.OpenFile("C:\MyFile.bin")
file.Seek(10,0)
' Going to the 10-th byte in the stream
Response.Write file.ReadText(5)
' Read 5 characters
' Skipping 10 more bytes after the last read character
pos = file.Seek(10,1)
' pos contains the absolute resulting position - 
' we may need it sometimes

Remarks:

Note that not all streams support navigation! All the streams built in this library are seekable - and the Seek method can be used with them, but some external streams will not support the feature. Check the external's application/object documentation to see if seeking is posible. Usually you can expect the feature to not be supported when the stream data is not immediately available - for example network oriented objects.

The SFStream supports streams no greater than 2GB in size.

Note that using the stream with SFRecord object bound allows you to navigate the stream through the SFRecord object (with record based positioning instead of byte based). However using the Seek method may give you advanced options - to skip some non-standard records or work with streams/files which contain records and other data in some of its parts.

Applies to: SFStream object

newObjects Copyright 2001-2006 newObjects [ ]