In my app, I'm using some code pilfered from "Palm Programming, The
Developer's Guide" by Rhodes and McKeehan.  The purpose of this code is to
reliably locate the "current record" upon app startup in the presence of
synchronization, which might make a record index unreliable.

Here's the code:

if (gCurrentRecord != kNoRecordSelected &&
     gCurrentRecord < DmNumRecords(gDB)) {
    DmRecordInfo(gDB, gCurrentRecord, &attr, &uniqueID,NULL);
} else {
    uniqueID = gAppPrefs.currentRecordID - 1;    // force not equal
}
    
// If we don't have the record find it by it's unique id.
// Then get it's info.
if ((gCurrentRecord != kNoRecordSelected) && (uniqueID !=
     gAppPrefs.currentRecordID)) {
    if (!DmFindRecordByID (gDB, gAppPrefs.currentRecordID, &gCurrentRecord))
        DmRecordInfo (gDB, gCurrentRecord, &attr, &uniqueID, NULL);
}

What sometimes happens for reasons I can't explain, is that the call to
DmFindRecordByID blows up with the error:

DataMgr.c, Line:4250, invalid uniqueID passed

Nothing odd happened prior to this error, and the uniqueID being passed in
_looks_ normal to me, so I'm at a loss to explain what's going on.  Quitting
and relaunching the app yields the same error, but reloading the database
from a backup (taken _after_ the problem hit) makes it go away.  If the ID
is invalid, why doesn't the function simply return a non-zero value as the
docs indicate, rather than throwing an exception?

Anybody have any idea what's going on here?

Thanks,

Mark Peters


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palm.com/devzone/mailinglists.html

Reply via email to