Storages & Files SFRecord object
See also object creation information - ClassID/ProgID 

SFRecord object, together with SFField and SFFilter defines a record of values of well-known types. This record then could be saved or read to/from any binary stream or file. The effect is a technique very similar to the technique used with the DB tables but applicable for files, memory blocks and anything else that resembles stream of bytes. If you ever heard/used to the so called flat files or files with random access - this is the way a script application such as ASP page could access them.

With SFRecord and SFField objects an ASP page could access files otherwise not understandable for it - such as dBase files or bitmap images and so on. With these objects the ASP page could do tasks usually performed only by application written in C++ or Delphi for example. Future evolution of these components will add more features and more flexibility - such as more types supported and some common tasks integrated (for better performance). The aim is obvious - more areas to become opened for the ASP pages and other scripts. 

How this works? The script defines a record - i.e. defines its fields and defines their types and sizes. With types known for each field the size of the entire record could be calculated - e.g. how many bytes it will occupy in memory or file. Actually this action requires one more step (done automatically) - the SFFilter object that defines additional details - for example how the strings will be saved - as ANSI characters or as UNICODE. SFRecord uses the default filter if nothing else is requested. Thus this step remains transparent, but you could access the automatically created filter if you need to (see the Filter property).

Then the script/ASP page is able to set the record's fields with some values or read them. To read/write the record from/to file or other stream the application connects the SFRecord object with the stream (see BindTo method). With this, through the SFRecord object, the application sees the file (or other stream) as set of records. The application can move the current position to any record and read or write it. Thus the file/stream behaves as table of records. It is similar to the tables in a DB, but note the  difference - the record definition is created by the script and not obtained from the file (of course - if the file contains such an information the script could read it and create the record). 

Record definition members
Field (default) Access field of the record
Count Count of the fields in the record
Name Name of the record 
Add Add a field object to the record
Clear Clear all the fields in the record
AddField Create and add a new field to the record
Remove Remove a field from the record
Replace Replace a field with another.
Connection to stream (and filter)
BindTo Bind the record to a stream through a filter specified or using the default filter.
UnBind Unbind the record
Filter Access the filter used for binding
ReBind Rebind to the stream. If come fields are added/removed/changed
Random access (DB table-like) reading and writing
RecordCount The total records in the stream
Move, MoveNext, MovePrev, MoveFirst, MoveLast Recordset like operations.
ReRead Reareads the record from the stream.
Update Saves (updates) the record to the stream.
Sequential read/write
Read Reads the record from the stream. The new position is immediately after the record. 
Write Writes the record to the stream. The new position is after the record.

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

 
newObjects Copyright 2001-2006 newObjects [ ]