Fixed it!  Now it all works.

Except one thing...

Earlier I noticed a problem when it went to sort my database.  It would find
a record's sort position and attatch it there.

The problem is with the record to be sorted.  The application defined
DmComparF is passed the correct function to compare the new one to, but the
new record is not passed correctly.  I am always getting things messed up
when it comes to pointers so that's probably my problem.

Here's the code to make the new record and call DmFindSortPosition().

<<<CODE>>>
 PatientType *record
 PackedPatientType *packed;
    ...
    ...  // Fill the record
    ...
 // Get the index of the new record.
 newIndex = DmFindSortPosition(db, record, NULL, &DB_ComparePackedRecords,
NULL);
<<<END>>>

Here's the DmComparF code.

<<<CODE>>>
Int16 DB_ComparePackedRecords(PackedPatientType *r1, PackedPatientType *r2,
 Int16 other, SortRecordInfoPtr info1, SortRecordInfoPtr info2, MemHandle
appInfoH) {
 // Don't care about the other mandatory parameters above
    ...
 char *s1, *s2;

 s1 = &r1->firstField;
 s2 = &r2->firstField;
    ...
}
<<<END>>>

I would expect 's1' to point to the start of the new record's string while
's2' points to the record it's comparing it to.  's1' points off into space
because the 'r1' points off into space while 's2' is fine.

Thanks.

Jimi



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

Reply via email to