I think I've found a workaround to get rid of the symptom and get back to a
normal state, even though I don't yet know the cause.  According to the
docs, unique IDs are three bytes long, yet the datatype for them, ULong, is
four bytes.  I suspect that a bad unique ID is one with a value greater than
0xffffff, so I installed code at startup to detect this, and then just
revert to displaying the first record, rather than trying to find the
current record.  This will at least avoid the blow up according to my
testing.

My assumption here is that _any_ value less than or equal to 0xffffff is a
valid unique ID and hence won't cause this blowup - can anybody confirm that
this is correct?

Thanks,

Mark Peters

> From: "Mark A. Peters" <[EMAIL PROTECTED]>
> Newsgroups: pilot.programmer
> Date: Tue, 18 Apr 2000 17:33:34 -0700
> Subject: "invalid uniqueID passed" error?
> 
> 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.  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?
> 
> The problem goes away if the database in question is reloaded via HotSync,
> which I guess is to be expected.
> 
> 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