by jadenews >> Tue, 3 Jul 2001 5:35:14 GMT
Hi,
An external function call requires a 32-bit floating point data type (float) which Jade does not implement. I'm passing therefore the value using a binary representation as Binary[4]. In order to get the correct float representation of the value I wrote a C++ library which takes the intended value as String and converts it into a Float representation. The following code snippet demonstrates this:
DLLExport float WINAPI ConvertJadeRealToFloat(char *jadeReal)
{
float converted;
int result;
int decimal, sign;
converted = (float)atof(jadeReal);
result = MessageBox(0,_fcvt(converted, 3, &decimal, &sign), "Conversion", 0);
return converted;
}
As far as I can tell the conversion returns the correct float representation. I defined the external function call in Jade as:
convertJadeRealToFloat(real:String):Binary[4] is ConvertJadeRealToFloat in dllbasic;
in the assumption that the library return value is "dumped" straight into the binary (which then would be passed to the external function requesting the 32-bit floating point.
However, using a Binary return value in the external function call always gives an error message (4038). But, using the Real return type gives the correct value (without crashing needless to say).
I pass the value into my library as a string to circumvent possible byte order problems.
Why does Jade not accept the Binary as a "bucket" for the float type of the library? Or, is there something wrong with the entire approach? Is it somehow possible to "mimick" a 32-bit floating point data type to pass into an external function (as Binary?).
Thanks a lot!
Jens