12-07-2005 11:50 AM
12-07-2005 01:42 PM
int CVICALLBACK CompareFunction(void *item1, void *item2)
Replace CompareFunction with any name you want. This serves as a wrapper for the FloatCompare () function
last statement within callback wrapper should be:
return FloatCompare (*item1, item2);
robskii
12-07-2005 02:17 PM
Oops!! bug: Do not use [return FloatCompare (*item1, item2)].
Replace FloatCompare with MyFloatCompareWrapper in ListFindItem() and scarf the following code.
Prototype:
int CVICALLBACK MyFloatCompareWrapper(void *item1, void *item2);
Function Definition:
int CVICALLBACK MyFloatCompareWrapper(void *item1, void *item2)
{
return FloatCompare (item1, item2);
}
robskii
12-07-2005 02:38 PM
12-07-2005 03:42 PM
12-07-2005 05:46 PM
You got it cpoore! delete the FloatCompare within the wrapper and replace it with FP_Compare ()!!
FP_Compare() gives control of the precision of the compare which I think you need in this case.
The key is the FP_CompareEpsilon from the toolbox.h file. I think you can add this *.h file to your project and change the FP_CompareEpsilon until the comparison works to the desired presision on the list.
With the implementation below, one can add break points to make sure the values look OK.
function def:
int CVICALLBACK MyFloatCompareWrapper(void *item1, void *item2)
{
static float itemA = *((float *) item1);
static float itemB = *((float *) item2);
return FP_Compare ((double) itemA , (double) itemB );
}
12-07-2005 07:11 PM - edited 12-07-2005 07:11 PM
Message Edited by Mert A. on 12-07-2005 07:14 PM
12-12-2005 12:18 PM
{
float itemA = *((float *) item1);
float itemB = *((float *) item2);
return FP_Compare ((double) itemA , (double) itemB );
}
The "static" declaration for itemA and itemB caused the compiler to return the error:
"Initializer must be constant"
Otherwise OK.
Chris