DLL calling parameter default?

Started by HPW, March 07, 2004, 12:06:17 AM

Previous topic - Next topic

HPW

Is there a default parameter with DLL calling?



> (setq mytest(get-string(hpwMimeEncodeString "")))

""

> (setq mytest(get-string(hpwMimeEncodeString "€")))

"gA=="

> (setq mytest(get-string(hpwMimeEncodeString nil)))

"gA=="



When I use nil or undefined symbol the DLL get a '€' (ASCII 128).

Is this a default or where does it come from.
Hans-Peter

Lutz

#1
No, there is no default parameter, it all depends how your function 'hpwMimeEncodeString' is written and how much parameters you pass, if you don't pass the exact numbers and types the function is written for, the result is not defined. On Windows it is also necessary to compile for the correct calling conventions.



Lutz

HPW

#2
The parameter is PChar and it is not a real problem.

I pass acidently a nil to it and wondered about the return-value.

When passing nil to the parameter,  I thought to get an empty string, but it was the '€'.

Maybe something which comes from delphi by default.
Hans-Peter

Lutz

#3
Here is an explanation if you are interested in newLISP internals:



In case that you pass a parameter which is not an integer, float or string newLISP passes the ardress of the lisp cell. I you case the receiving imported routines took this address as a string pointer and the value the cell address was pointing to, happens to be "€" which is the lowest byte of the type word in the lisp cell.



You can simulate this by doing a:



(get-string nil) => "€"



or



(char (get-string nil) ) => 128



This is the type byte of the lisp cell nil



Lutz

HPW

#4
Thanks for the explanation.

So we have to check the passed parameter first on nil.
Hans-Peter