"Dan Samber" <[EMAIL PROTECTED]> wrote in message
news:49567@palm-dev-forum...
> To add a new record to a database, call DmNewRecord. This routine
> can insert the new record at any index position, append it to the
> end, OR REPLACE AN EXISTING RECORD BY INDEX.
> It returns a handle to the new record.
>
> I'm not certain what they mean here.... does the existing record get
overidden?
> OR is the existing record's index simply adjusted? (Making this NOT a
modify
> operation).
The latter. DmNewRecord inserts the new record, adjusting the indices of the
following records as necessary. To overwrite an existing record, use
DmAttachRecord. (But note that DmAttachRecord can also be used to insert a
new record, just like DmNewRecord except that it doesn't allocate the chunk
that contains the record's data.)
> I'm pretty sure I have to do steps #1, #2 and #3... but I'm seeking
verification.
Another alternative to modify an existing record is to:
1) Use DmNewHandle to create a chunk to contain the new contents of the
record.
2) Use MemHandleLock, DmWrite, and MemHandleUnlock to fill in the contents
of the new record.
3) Use DmAttachRecord to put replace an existing record with the new one.
4) Use MemHandleFree to free the chunk with the old contents of the record.
The advantage of this approach is that it's less likely to corrupt the
database if the process is interrupted, whether due to a bug or the user
forcing a reset. You can find examples of both approaches in the PIM apps.
--
Danny
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/