BindTo method Binds
the SFRecord object to a stream (or file). Binding occurs through the
default filter or through an external filter (if specified).
Syntax:
recordobject.BindTo strm [, filter]
Parameters:
recordobject - an initialized SFRecord object. There is no
sense to invoke BindTo without some Fields added to the record.
strm - An object representing a stream. Can be any SFStream
object or object that supports the standard COM interface - IStream.
SFRecord will automatically try all the possible ways to access the
srtream.
Examples:
Set main = Server.CreateObject("newObejcts.utilctls.SFMain")
Set file = main.OpenFile("somefile.bin")
Set rec = Server.CreateObject("newObejcts.utilctls.SFRecord")
rec.AddField "A", vbString, 20
rec.AddField "B", vbLong
rec.AddField "C", vbDouble
rec.BindTo file
Remarks:
Binding operation creates or/and attaches a filter to the record.
Then the filter is called to calculate the actual size of one record -
as the record will be represented in the file/stream. This prepares
the record for Move, Read and Write operations - i.e. after the
binding the size of the record is known.
The filter role is to encode/decode the data to/from the stream.
For example you may want to save the strings as ANSI using certain
code page - the filter does this for you. Therefore without the filter
the size of the record cannot be determined because there is no
information how the data will be saved/read. To simplify the usage of
the object we implemented default filter behavior - in other words the
default filter is created if none is specified.
If any settings of the record or the filter are changed the ReBind
method must be called in order to calculate the correct size of the
record.
Note that the binding occurs to the "raw" streams. In
other words the SFRecord-SFFilter pair works over the IStream
interface. This allows usage of external components which support the
standard IStream interface with the SFRecord object not packing them
with SFStream object first.
If you need to access a stream with combined structure (e.g. some
parts are clear text for example, other parts are binary records) you
will need to access the stream through SFStream and SFRecord object at
the same time. We recommend you to first create the SFStream object
and bind the SFRecord to it. Because the SFRecord object relies on the
stream position kept in the stream itself the navigation done through
SFStream will affect the current position for the SFRecord and you
will be able to read/write the "plain" parts of the file,
then position the SFStream over the first byte of the
"record" part of the stream and continue with the SFRecord.
In case of read operations you will need to call ReRead to synch the
data in the record after the re-positioning operation.
Applies to: SFRecord object
See also: ReBind
Supported on:
Windows 95/NT and later
Windows CE 3.0 and later
Pocket PC/Windows Mobile 2003 and later
Windows CE.NET 4 and later
|