On Mon, 3 Jan 2000, Dalmer Azevedo wrote:

> Hi scott,
> 
> Probably you are forgeting to lock the memory before manipulating it.
> The memory manager can move handles and memory chunks for other locations in
> order to optimize the memory
> usage. You have to warn it that a particular chunk of memory will be used
> and it should not touch it.
> 
> When allocating or accessing handles you should lock memory before using it.
> This is done using the function MemHandleLock.
> I think that's your problem.
> 
> As an example:

<snip>

Thanks Dalmer, but that is not the problem. I was making an invalid
assumption about the way a record's index is maintained by the PALM os.
At one point, my app would create an initial database by appending records
to the end. So initially there was a one-to-one correspondence between a
record's index in the database and the sequence at which it was added. So
making a hard-coded reference to an index would not cause my app to barf.
Later, I chose to 'insert' records according to some comparsion criterion.
I maintained the assumption that the data base indices 0-N would still
reference the N (minus 1) records I has just inserted. This was not true.
Now, maybe it 'should have' been true, but there was a bug in my insertion
algorithm. But that's really a moot point. The lesson learned is that the
data base record indices should be treated in a transitory manner. 


DmQueryNextInCategory (with the categories set to dmAllCategories) will
enable you to sequence through all the records in the data base. If you
have some sort of relational data base and need to sequence through your
records in some other order, then I learned of two ways in which this may
be done. First, you may re-sort the data base according to the order in
which the records need to be referenced and then use
DmQueryNextInCategory. However, this may not be acceptable if you need to
frequently change the order. So the other solution that I know of is to
use the records' unique ids to cross reference to other records. Then you
can use DmFindRecordByID to find the index of a record given its unique
ID.

I'm sure other solutions for cross-referencing records exist. Does anyone
else have a better solution?

Scott

Reply via email to