This may have been already answered in this thread, sorry if I missed it.
What if the lengths of str1 and str2 are not known? How do you then get
access to num1 and num2(and str2). In some, if not most cases, using fixed
legnth records would be a waste of valuable space on the Palm. ie. Using 50
bytes to hold only 5+1(NULL) = 6 of my name "Lenny\0".
I need to do this in my recordPack/Unpack procedures, and I am trying to
save space by not using fixed length records.
Thanks,
Lenny
----------
> From: Jim Schram <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: RE: Using DmQuickSort ??
> Date: Monday, March 22, 1999 5:51 PM
>
> At 2:29 PM -0800 1999/03/22, Michael S. Davis wrote:
> >Ok, almost got it. Let's say my compare functions performs
> >as follows:
> >
> >double elem1 // variables within a record
> >double elem2 // variables within a record
> >
> >if(elem1 < elem2){ return -1 };
> >if(elem1 == elem2){ return 0 };
> >if(elem1 > elem2){ return +1 };
> >
> >Now my problem is this. this is easy if I declare elem1 and elem2
> >but how do I refer to these as part of the record.
>
> Assuming fixed-sized fields in your records (which allows you to declare
the record as a C struct) just declare the first two 'void *' pointers as
pointers to your record struct type and defererence the appropriate member
using the -> notation, like this:
>
> typedef struct MyDBStruct { // hypothetical fix-sized data record
> char str1[50];
> double num1
> char str2[25];
> short num2;
> } MyDBStruct;
>
> typedef MyDBStruct* MyDBStructPtr;
>
> Int MyCompareFunc( MyDBStructPtr p1, MyDBStructPtr p2, ...)
> ...
> if ( p1->num1 < p2->num1 ) return -1;
> etc.
>
>
> Regards,
>
> Jim Schram
> 3Com/Palm Computing
> Partner Engineering