> After successfully resizing a record, is the index still the same?

Yes. However, any edit to a record may invalidate the current sort order. So
you may want to move the record once you've resized it and changed its
contents.

> Another question: is there any advantage to using DmNewRecord,
> DmAttachRecord, etc. instead?

DmNewRecord allocates and attaches, all in one API call. You can do these in
separate steps with DmNewHandle and DmAttachRecord. This allows you to
determine the correct sort position before inserting the new record. Some of
the PIM apps do this. Consider the following basic algorithm:

1. Edit a record.
2. Find the new sort position using a binary search.
3. Move the record to the new position.

There are two challenges with this. First, you have to compensate for the
old record being deleted if you're moving the record ahead rather than back.
Second, and more important, you can't do a binary search if any of the
records are out of order. One workaround is to detach the record, edit it,
find the new sort position, and then attach the record again. Another reason
to use this approach is that it reduces the likelihood that a reset will
leave the database in an invalid state - not being sorted properly. You
could just call DmInsertionSort to resort all the records, but this would be
slower.

> I need to add some info to an existing record in a sorted database,
> and I don't want to disturb the sort order (and don't want to have
> to re-sort).

As long as your edit doesn't affect the record's sort position, you don't
have to worry about resorting.
--
Danny @ PalmSource

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to