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