448
Platforms
©2000-2008 Tibbo Technology Inc.
Now let's suppose you want to find a record whose "last name" is "Smith". For this
we search starting from file offset 21, which is the offset of the "Last name" field
within the record (this assumes that the first record starts right from the beginning
of the file, which is usually the case). The search step will be 54 -- the size of the
record:
Dim
dw
As
dword
'try to find the record with the "Last name" set to "Smith"
dw=fd.find(21,chr(5)+"Smith",1,FORWARD,54)
'notice how we supply the
string length
If
fd.laststatus<>PL_FD_STATUS_OK
Then
'some disk-related error
Else
If
dw<>0
Then
'found- convert into the record number and process...
dw=dw/54
Else
'not found...
End
If
You can also search back, but remember that this is less efficient (takes ~ 50%
longer) compared to forward searches.
Closing Files
Files are closed using the
method. The method is performed on a
currently selected file (selection is made through the
property).
Proper file closing is only required if you made changes to the file. If you only read
data from the file you don't have to bother closing it -- you can
another
file right "on" the same file number. Doing so on a file that was changed may
cause some recent changes to be lost. To prevent this, use the fd.close method or
method. Note that fd.flush does not depend on the current fd.filenum
value and works globally on any most recently changed file.
Direct Sector Access
Direct sector access allows you to work with physical sectors of the flash chip
directly, without the need to create and manage any files. You work with sectors
through two identical 264-byte RAM buffers numbered #0 and #1 (each flash
sector contains 264 bytes of data). The
property selects one of the
buffers as the source/destination for the data (see the drawing below).
460
463
443
466
458