Float parameter problem when making a DLL

Just starting out? Need help? Post your questions and find answers here.
gpetersz
User
User
Posts: 39
Joined: Fri May 20, 2005 11:24 am
Location: Budapest, Hungary
Contact:

Float parameter problem when making a DLL

Post by gpetersz »

Hi Everyone,

I made a very tiny DLL just to test if I could do it.
The source seemed something like the example one in the help

ProcedureDLL.f own_msg(p_msg.s, p_value.f)
l_value.f = p_value * 2
Result = MessageRequester(p_msg, p_msg + " " + str(p_value), #PB_MessageRequester_Ok)
ProcedureReturn(l_value)
EndProcedure

The caller was
If OpenLibrary(0, "test.dll")
Rvalue.f = CallFunction(0, "own_msg", "Hi there", 1)
EndIf

It worked fine except that the DLL procedure received 0 through the parameter p_value. If I changed the p_value type to p_value.l (long),
it worked.

Does anybody met something before? Or should I know something specific about this? It can be worked around really, but...
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

Change this line:

Code: Select all

Rvalue.f = CallFunction(0, "own_msg", "Hi there", 1)
to this

Code: Select all

Rvalue.f = CallFunction(0, "own_msg", "Hi there", 1.0)
Purebasic needs the ".0" to know this is a float, else sends an integer.
@}--`--,-- A rose by any other name ..
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

Further to this, check out this thread:

viewtopic.php?p=111280#111280

(The post by El_Choni.)
@}--`--,-- A rose by any other name ..
gpetersz
User
User
Posts: 39
Joined: Fri May 20, 2005 11:24 am
Location: Budapest, Hungary
Contact:

Post by gpetersz »

Thanks.
Post Reply