Page 1 of 1
How to return a string from PROCEDUREDLL????
Posted: Mon Nov 17, 2003 8:52 pm
by Sveinung
How can I get the string value from my dll???
Code: Select all
ProcedureDLL Read_String_DB(colum)
UseDatabase(1)
res.s=GetDatabaseString(colum)
ProcedureReturn res
EndProcedure
What the h*** am I doing wrong
Sveinung
Posted: Mon Nov 17, 2003 9:04 pm
by Dreglor
i not sure but try
ProcedureDLL.s Read_String_DB(colum)
Posted: Mon Nov 17, 2003 9:50 pm
by GPI
Better return a pointer to a global variable
global ReturnString.s
procedurereturn @ReturnString
Posted: Tue Nov 18, 2003 2:04 pm
by Froggerprogger
So use a procedure as (I think it's the same as GPI meant):
Code: Select all
ProcedureDLL Test()
Global result.s
result = "this is a string"
ProcedureReturn @result
EndProcedure
and call it by
Code: Select all
OpenLibrary(0,"myDLL.dll")
procedureresult.s = PeekS(CallFunction(0,"Test"))
Debug procedureresult
You even might use an independant global variable named 'result' inside the main program.
You cannot use a protected variable inside the DLL because then it's value is pushed on the stack which gets 'cleaned' when leaving the procedure (though strings are handled slightly different). A CallFunctionS(tring) (and a CallFunctionF(loat)) would help here in future.
Posted: Wed Nov 19, 2003 6:27 pm
by Sveinung
Thank Froggerprogger!!!!
Worked fine!!!!
Sveinung
Posted: Wed Nov 19, 2003 6:28 pm
by Sveinung
AND GPI!!!!
Sveinung