I.T. Discussion Community!
-Collapse +Expand
Paradox
Search Paradox Group:

Advanced
-Collapse +Expand Paradox To/From
To/FromCODEGuides
-Collapse +Expand Paradox Store
PRESTWOODSTORE

Prestwood eMagazine

August Edition
Subscribe now! It's Free!
Enter your email:

   ► MB LobbyCorel Paradox / ObjectPAL Coding BoardParadox Third Party Software, DLLs, and Controls Topic   Print This     

Trouble passing floating-point parameters to C++ D

Trouble passing floating-point parameters to C++ D in Paradox Third Party Software, DLLs, and Controls topic (part of our Corel Paradox / ObjectPAL Coding group).

Quick Search: Trouble   passing   floating   parameters   Trouble passing   Trouble passing floating   point parameters   C D  
Deleted Member
Hi everyone.


I've been working on a problem off and on for a while now. Perhaps someone here can help me figure out what's going on. I apologize in advance for this being a little long, but I don't want to skip any details that may be important.

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 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 18 years ago (Thread Starter)
Comment Quote
About deleted_member -Collapse +Expand
Visit Profile
Inactive member.
Member does not subscribe to this thread.
Email Not Verified!
Once email is verified, we will review and approve the account.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #1719, 1 replies
Thread Started 4/11/2001 9:46:00 AM
View Counter=1842
Last Reply Posted 4/16/2001 8:52:00 AM)
Location=-- USA 
Joined=12 years ago   MB Posts=184  
Most Recent Post
Deleted Member
Well, here's an update: I haven't figured this one out yet!

I'm still hoping to find someone who can either (a) back me up on this one and say, "Yeah, I tried that too and it's just not happening with Paradox 9" or (b) point me in the right direction.

I've spent more time than I care to admit working on this problem. Extensive research through books, the Internet, and my own posted questions have gotten me nowhere. I called Corel about this a while back to see if they were aware of any bugs with Paradox 9 that I may be experiencing, and the answer I got from the Tech Support person was, "Um...I don't really know anything about C++". Terrific.

So, the search continues. Thanks for listening to my rant; unsolved problems make me frustrated!

--Paul C.

P.S. I realized after my initial post that the more appropriate category for this question would have been "Paradox - ObjectPAL". My apologies! I was thinking that this was a Paradox 9 specific category, not a book specific category. If a moderator could move this thread I would definitely appreciate it!
 Posted 18 years ago (Thread Starter)
Comment Quote
About deleted_member -Collapse +Expand
Visit Profile
Inactive member.
Member does not subscribe to this thread.
Email Not Verified!
Once email is verified, we will review and approve the account.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #1750 (Level 1.1)  Reply to 1719
Thread Started 4/16/2001 8:52:00 AM
View Counter=2
Location=-- USA 
Joined=12 years ago   MB Posts=184  

Revive Thread!

Add a comment to revive this old thread and make this archived thread more useful.

Write a Comment...
Full Editor
...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.


Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P1251A1
Enter key:
Icon: A Post    Thread    Idea    Important!    Cool    Sad    No    Yes    Includes a Link...   
Thread #1719 Counter
1842
Since 4/2/2008
Follow PrestwoodBoards on: 


©1995-2019 PrestwoodBoards  [Security & Privacy]
Professional IT Services: Coding | Websites | Computer Tech