christy wrote:
I need to find a matching record from the databse (by fid and sid pair). If there is a match, I can subtract 1 from the return-value of DmFindSortPosition. However, how do I know that there is in fact no match for fid + sid pair? DmFindSortPosition tells me the next available position. It didn't indicate whether or not a match is found. Am I using the wrong function all together?
DmFindSortPosition() is not intended to find the index of an existing record, rather, it is intended to tell you where to insert a new record.
Here's a cut'n'paste from the Palm OS 4.0 doc about what happens when the new record matches an existing record. -------------------------------------------------------- If newRecord has the same key as another record in the database, DmFindSortPosition assumes that newRecord should be inserted after that record. If there are several records with the same key, newRecord is inserted after all of them. For this reason, if you use DmFindSortPosition to search for the location of a record that you know is already in the database, you must subtract 1 from the result. (Be sure to check that the value is not 0.) -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
