>From: "JB Parrett" <[EMAIL PROTECTED]>
>> >If I delete a record DmNumRecords() counts it anyway.
>> >How can I count only the records that are not deleted?
>>
>> Use DmNumRecordsInCategory(gDB, dmAllCategories); This skips the
>> deleted records.
>
>There is a problem with using DmNumRecordsInCategory: it can be slow. Does
>anyone know of a method that is as fast as DmNumRecords but counts only
>non-deleted records?
'Slow' depends upon your database - DmNumRecordsInCategory just
traverses the database's record list, checking the attribute/category
byte. For databases of up to a few hundred records, the amount of
time taken for completion is negligible if you are using it for form
initialization or as part of some other UI function, at least in my
experience.
However, if you plan on using this in a tight loop or have thousands
of records, you might want to keep a count of the deleted records in
the database appInfo block and write a small convenience function
that subtracts that count from DmNumRecords, which is always fast (db
header lookup O(1)). Don't forget to update the count properly for
DmArchiveRecord and DmDeleteRecord but ignore it for DmRemoveRecord.
Also, you'll need to update the appInfo block after HotSync if your
conduit calls SyncPurgeDeletedRecords or in some other way deletes
records.
JB
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palm.com/devzone/mailinglists.html