npm37  wrote:
--- In [EMAIL PROTECTED], Matt Graham <[EMAIL PROTECTED]> wrote:
I'm obviously missing the point here, how do pass the string into the function? Do I declare a PackedRecord pointer type to pass, if so how do I get a handle to it without using DmRecordNew? If I simply declare a packed record and say something like;
ok, you have a bunch of sorted, packed records in your database that look something like this (numbers are record index):
0 - "123"
1 - "ABC"
2 - "Hello"
3 - "Wednesday"
4 - "Yesterday"

Now, say you want to find "Hello", this is sort of what it looks like you would do based on your previous posts:

char *idname = "Hello";
index = DmFindSortPosition( dbP, idname, 0, compar, 0 );

You might have to cast idname to a (void *), I'm not sure.

index would come back as 3, because it comes back as 1 more than any matched records. so you have to check 2 to make sure that record 2 actually does match exactly idname and isn't just the previous record in order. For example if
idname = "Hello!!!";
DmFindSortPosition() would return the same index but it wouldn't be a match.
Because your compare function treats the records as a string, you don't need to pass anything more complicated to DmFindSortPosition because the compare function will just treat it like a string anyway.

matt


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


Reply via email to