Page 1 of 1

Posted: Mon Jan 13, 2003 5:24 am
by BackupUser
Restored from previous forum. Originally posted by mindplay.

I'm calling a function in a DLL, with CallFunction, and it returns a pointer to a string - how do I copy that string into an ordinary string variable so I can print it out?

My idea was to make a little procedure that takes a point as an argument, and returns a string, so I wrote this:

Procedure.s PStr(*str.s)
ProcedureReturn *str.s
EndProcedure

and then I would use it like this:

mystring = PStr(CallFunction(0, "GetDeviceInfo"))

but it won't compile my call to PStr() - it says "bad parameter type, a string is expected" ... but how come a string is expected for PStr, when I've specifically declared the parameter as a POINTER to a string, not just a string??

help, please! thanks :)

Posted: Mon Jan 13, 2003 8:07 am
by BackupUser
Restored from previous forum. Originally posted by dreamer.

Hi mindplay!

First you have to set a global stringvar out of the ProcedureDLLs. Then you have to return the pointer of this global var und you can get the information with PeekS out of the functioncall. Look at this example:

Code: Select all

GLobal Back.s

ProcedureDLL.l Func(String1.s, String2.s)
  Back.s = String1.s + String2.s
  ProcedureReturn @Back.s
EndProcedure
And than you must call it like this:

Code: Select all

 MyString.s = PeekS(CallFunction(0, "Func", "Hello ", "World!"))
Hope this helps!