Hi
I�m trying to use DmFindSortPosition to find a packed
record in database. My packed record looks like this;
typedef struct { // record with variable length fields
char idname[1];
} PackedNoteInfo;
And I unpack it into a struct that looks like this,
typedef struct {
const char *idname;
const char *note;
} NoteInfo;
using the public unpack routine.
I�m using DmFindSortPosition with a simple compare
function that looks like this;
UInt16 CompareNote(void *r1, void *r2, Int16
UnusedInt16, SortRecordInfoPtr unused1,
SortRecordInfoPtr unused2, MemHandle appInfoH)
{
#pragma unused(unusedInt16, unused1, unused2,
appInfoH)
PackedNoteInfo *rec1 = (PackedNoteInfo *) r1;
PackedNoteInfo *rec2 = (PackedNoteInfo *) r2;
Int16 Result;
const char *s1 = rec1->idname;
const char *s2 = rec2->idname;
Result = StrCompare(s1, s2);
return Result;
}
This seems to work OK. My problem is when I try to
find a new record in the database, how do I initialise
a record with the key value for the compare function
to use? The only examples I can find in the archives
all have Ints as the key and simply do something like
PackedNoteInfo findRecord;
findRecord.key = someint;
index = DmFindSortPosition(gNotesDB, &findRecord, 0,
(DmComparF*) CompareNote, 0);
This wont work in my case, because my key is a
variable length string, findRecord.idname, I can�t
simply assign a value to it without running into
memory problems.
Can anyone help with this problem?
Thanks,
Nick
__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/