Page 1 of 1

Float parameter problem when making a DLL

Posted: Mon Dec 12, 2005 11:22 am
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...

Posted: Mon Dec 12, 2005 11:35 am
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.

Posted: Tue Dec 13, 2005 2:06 am
by Dare2
Further to this, check out this thread:

viewtopic.php?p=111280#111280

(The post by El_Choni.)

Posted: Thu Dec 15, 2005 7:39 am
by gpetersz
Thanks.