Page 1 of 1
Posted: Tue Apr 09, 2002 1:43 pm
by BackupUser
Restored from previous forum. Originally posted by VeKem.
Hello,
I tried to use PureBasic float variables as parameters for an external dl-function (inside a dll written in PowerBASIC). The float types seems to have a specialo/non standard format (?). Insode PowerBASIC there is a single type (also 32bit float), but the results are trash.
Knows anybody handling the PureBasic floats outside in a correct way?
Thanks!
Posted: Tue Apr 09, 2002 1:46 pm
by BackupUser
Restored from previous forum. Originally posted by VeKem.
I really don't know why this message comes 4 times... (using Opera) - sorry!
Posted: Tue Apr 09, 2002 2:45 pm
by BackupUser
Restored from previous forum. Originally posted by Rings.
Do you have sources to both, PowerBasic and Pure (coz i have them both)
to evaluate and test them ?
Its a long way to the top if you wanna .....CodeGuru
Posted: Tue Apr 09, 2002 3:13 pm
by BackupUser
Restored from previous forum. Originally posted by VeKem.
Hi Rings,
have sent the sources to your e-mail-address directly.
Thanks
Posted: Tue Apr 09, 2002 4:17 pm
by BackupUser
Restored from previous forum. Originally posted by fred.
The float types seems to have a specialo/non standard format (?).
PureBasic use the regular, native x86 32 bit float representation. This format is perfectly compatiable with all C/C++ compiler on Windows, so I guess you better have to tell to the PowerBasic team how they have coded that .
Fred - AlphaSND
Posted: Tue Apr 09, 2002 4:51 pm
by BackupUser
Restored from previous forum. Originally posted by Rings.
x.f = 12.589
use
CallFunctionFast(lpProc.l, PeekL(@x) )
instead of
CallFunctionFast(lpProc.l, x.f)
This works, but i think there is a problem with floats(single).
Only Longs are dropped on the stack.
Its a long way to the top if you wanna .....CodeGuru
Posted: Tue Apr 09, 2002 5:13 pm
by BackupUser
Restored from previous forum. Originally posted by fred.
Hum, may be I've spoken a little bit faster . I will take a look.
Ok, here is the explaination:
It can't be fixed for now, CallFunction() is a purelibrary and I've fixed the parameter to #Long so the floats are automatically transformed to long.
Yhe PeekL() solution is the way to go for now. I will add an #Any paramater to allow every types in the next version..
Thanks for this report !
Edited by - fred on 09 April 2002 18:21:32
Posted: Tue Apr 09, 2002 6:01 pm
by BackupUser
Restored from previous forum. Originally posted by El_Choni.
BTW, Fred, I can't find any doc about how to code library functions with variable arguments number, and how to know how many arguments have been passed. Is that number passed in edx or how? What to put in the .Desc file?
Thanks in advance (BTW, Internet has returned home
Bye,
El_Choni
Posted: Tue Apr 09, 2002 6:16 pm
by BackupUser
Restored from previous forum. Originally posted by VeKem.
Thanks to Rings!
Fred,
thanks for your info, PowerBasic also uses internally the standard float (single) type. PeekL(...) told us the solution. Fine, you plan this #Any-parameter!
Addition: could you make a Declare-Statement for DDL-Calls, something like
Declare DllFunc.l(ParCount) lib DLLName$
...
;Pure-Code:
result = DllFunc(...)
so we can use it in PureBasic very easy? (No OpenLibrary, IsFunction, CallFunction...)
Posted: Tue Apr 09, 2002 6:42 pm
by BackupUser
Restored from previous forum. Originally posted by Paul.
I hope the names don't change...
I find OpenLibrary and CallFunction very easy to use and the names make sense to me. (and they follow the naming convention of other PB commands... OpenWindow, OpenConsole, OpenFile, OpenDatabase, etc.)
Just my 2 cents

Posted: Tue Apr 09, 2002 7:17 pm
by BackupUser
Restored from previous forum. Originally posted by fred.
I will probably add an extra function which will do all this:
CallLibraryFunction(LibName$, FunctionName$, Args...). But it will have a performance impact..
Fred - AlphaSND
Posted: Tue Apr 09, 2002 7:45 pm
by BackupUser
Restored from previous forum. Originally posted by VeKem.
Paul,
I think, the naming convention of PB commands is good but if you only needs one command accessing a ddl function makes easier coding and
Fred,
thanks you thinking about
CallLibraryFunction(LibName$, FunctionName$, Args...) !
>But it will have a performance impact
Not much, because calling (internally) OpenLibrary etc. will force Windows only to increment a counter on the dll loading. In other languages I used to load the librarie ones (or before a whole block accessing it) and close it at the program end (or after the calling block). So an OpenLibrary is okay, but why identify a library with own #Library-Numbers, its handle is enough to do this.
What happens I open two different libs using the same Number?
OpenLinrary(0, "own01.dll")
OpenLinrary(0, "own02.dll")
Thanks for your great job on PureBasic!
Markus Vedder-Kemnitzer, Germany
Registered PureBasic-User
Posted: Tue Apr 09, 2002 7:47 pm
by BackupUser
Restored from previous forum. Originally posted by Franco.
I will probably add an extra function which will do all this:
CallLibraryFunction(LibName$, FunctionName$, Args...). But it will have a performance impact..
Fred - AlphaSND
So PureBasic will be faster
And will a program be faster only if I use CallLibraryFunction
Have a nice day...
Franco
Sometimes you have to go a lonely way to accomplish genius things.
Posted: Tue Apr 09, 2002 10:11 pm
by BackupUser
Restored from previous forum. Originally posted by fred.
What happens I open two different libs using the same Number?
OpenLinrary(0, "own01.dll")
OpenLinrary(0, "own02.dll")
The first library is automatically closed/freed. That's the magic of using number instead handle. You never have to take care of previously objects for the same number. This is valid for any library.. For example, LoadImage(0,"2.bmp") followed by LoadImage(0,"1.bmp") with free the first one. In other langage, you will have to call FreeImage(0) before.. And of course, PureBasic can keep track easely (and very quickly) of all objects and free them when the program end/crashs.
Fred - AlphaSND
Posted: Sat Apr 13, 2002 4:34 pm
by BackupUser
Restored from previous forum. Originally posted by VeKem.
Fred,
I understand this behavoiur of PureBasic, but what's about this
(something like pseudo code):
;***********************************
; ...
Declare ExternalProc(value.l)
If OpenLibrary(0, "user32.dll")
...
Result.l = CallFunction(0, "FuncName", ...)
ExternalProcedure(Result.l)
Result.l = CallFunction(0, "AnotherFuncName", ...) ; but there is no "0"-Library
CloseLibrary(0) ;...
EndIf
;...
Procedure ExternalProc(value.l)
; this could be a procedure from another coder or inside an include file,
; something I didn't write myself and (!) I do not want to check every
; time using it
If OpenLibrary(0, "mydll.dll") ; => closes the *actuall* with "0" opened dll!
;... doing something
CloseLibrary(0) ; now no "0"-Library opend any more
EndIf
EndProcedure
;***********************************
There is no way to check which number actually is used to avoid an automtic closing. What's you opinion on this? Thanks!
Markus Vedder-Kemnitzer, Germany
Registered PureBasic-User