Last summer I made an attempt to migrate a Paradox 7 (32-bit) application to
Paradox 9. Everything went smoothly, until I noticed a floating-point
parameter passing problem between Paradox 9 and a C++ DLL. Any
floating-point values that were passed to a function in the DLL were being
received as garbage. I posted my findings here and received a reply stating
that Corel may have changed the way Paradox handles floating-point values. I
finally had to abort the project and stick with Paradox 7, which had no
issues with the DLL.
Recently, I have come back to this task with some more ideas, but every
attempt I have taken has failed. I have simplified the code down to the
extreme basics in order to isolate the problem. Here is what it looks like:
C++ code
(C++ Builder 4 - Created new DLL, and added the following test function.)
extern "C" __declspec(dllexport) double ParameterPassing( double doubleTest,
short int integerTest, char *stringTest ) ;
extern "C" __declspec(dllexport) double ParameterPassing( double doubleTest,
short int integerTest, char *stringTest ) {
double returnTest;
char buffer[80];
// Message boxes to view each of the passed parameters
sprintf(buffer, "%f", doubleTest);
MessageBox(NULL, buffer, "doubleTest, as received by C++", MB_OK);
sprintf(buffer, "%d", integerTest);
MessageBox(NULL, buffer, "integerTest, as received by C++", MB_OK);
MessageBox(NULL, stringTest, "stringTest, as received by C++",
MB_OK);
// Return a value as a test.
returnTest = 3.14;
return returnTest;
}
Paradox code
(Paradox 9 with SP 3 - Created one form with a textbox to see the return
value, and a button to execute the code.)
Uses block:
Uses myDLL
ParameterPassing( doubleTest cdouble, integerTest cword, stringTest cptr
)
cdouble [STDCALL]
endUses
pushButton event:
method pushButton(var eventInfo Event)
;; return_value is my textbox to see what comes back.
return_value = ParameterPassing( 3.14, 5, "Hello, World!" )
endMethod
OK. The C++ compiler is set for STDCALL calling convention. I compile the
code to a DLL, and then run the Paradox form. No problems so far. Trigger
the pushButton event, and the first thing I get is "Unexpected: Floating
point error was generated." I click "OK", and then trigger the event again.
This time, there is no error message, and my message boxes from the C++ DLL
start popping up. The doubleTest variable displays as "-NAN", but the
other two variables display just fine. And the real kick-in-the-head is that
my 3.14 return value comes back with no problems.
If I switch everything over to CLONGDOUBLE/long double, I get the same
results, except that the DLL tells me that doubleTest is "-0.0000000".
I think I have ruled out problems with the calling conventions. It seems
that
if there is a problem from that aspect, Paradox can't even find the DLL's
function.
So that's my story. If I didn't need Paradox 9's ability to publish a report
to a file, I would just stick with 7. If anyone has any ideas at all, please
let me know! I would REALLY appreciate it!
Thank you!
--Paul C.
----- Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web -----
http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups
NewsOne.Net prohibits users from posting spam. If this or other posts
made through NewsOne.Net violate posting guidelines, email ab...@newsone.net