I rather assumed that deleted records were always supposed to be at the end
of a Palm OS database. I thought that one should be able to do something
like this:
while (recordNum < numOfRecords)
{
recordH = DmQueryRecord (MyDB, recordNum);
if (!recordH)
break; // First deleted record... all done
....
recordNum++;
}
I had copied some code out of the memopad routine to handle the insertion of
the Datebk3 icon and timezone records in my little dbSetup application. But
I found a bug - after dbSetup ran, Datebk3 STILL could not find those
records. I had also been puzzled as to why Datebk4 was sometimes not finding
memopad records that were clearly displayed in the MemoPad application.
After some research, I discovered that if the Memo database was not alpha
sorted, valid records were appearing AFTER deleted records. I just assumed
it was a silly bug I had introduced in dbSetup and Datebk4, so imagine my
surprise when I found out that indeed the Built-in ROM MemoPad application
has this exact same problem.
Now the MemoPad app did not have a problem with this apparent anomaly as it
uses DmQueryNextInCategory() -- a routine that happens to scan through ALL
Deleted records until it gets to the end of the database. Even though it
will skip over deleted records, rather than quitting at that point, it keeps
on searching and does NOT give up on the first deleted record, which is why
the memoPad application can still find a record even though it's sorted
after deleted records.
MemoPad inserts a new record at the very end of the database (after all
deleted records) and then calls MemoSortRecord(). If you look at
MemoSortRecord() you will see at the start:
sortOrder = MemoGetSortOrder (dbP);
if (sortOrder != soAlphabetic) return (0);
So sure enough if the database is not sorted, it just leaves the record at
the very end - after all the deleted records. This code is still in the
V-3.5 OS.
So the $64,000 question is: is this just a bug in the MemoPad application
that has survived ALL this time? Or is the statement that deleted records be
put at the end of a database a "recommendation" rather than a Palm OS
"Requirement"?
Anyone care to comment on this?
I think it's a bug anyway you look at it ;)
BTW removing the line of code:
if (sortOrder != soAlphabetic) return (0);
would correct that problem in the MemoPad application as the subsequent sort
routine will then properly force the record to the end of the non-deleted
records. For now, I have added code to Datebk4 and dbSetup to look for valid
records AFTER deleted records...
____ ____
/ ___) / ___)
( (___ ( (___
\____)heers! \____)ESD
Pimlico Software, Inc.
Home of DateBk3 and WeekView: http://www.gorilla-haven.org/pimlico
The Dewar Wildlife Trust, Inc.
Home of Gorilla Haven: http://www.gorilla-haven.org
. . . . . .
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palm.com/devzone/mailinglists.html