How to return a string from PROCEDUREDLL????

Everything else that doesn't fall into one of the other PB categories.
User avatar
Sveinung
Enthusiast
Enthusiast
Posts: 142
Joined: Tue Oct 07, 2003 11:03 am
Location: Bergen, Norway

How to return a string from PROCEDUREDLL????

Post 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
Dreglor
Enthusiast
Enthusiast
Posts: 759
Joined: Sat Aug 02, 2003 11:22 pm
Location: OR, USA

Post by Dreglor »

i not sure but try

ProcedureDLL.s Read_String_DB(colum)
~Dreglor
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Post by GPI »

Better return a pointer to a global variable

global ReturnString.s


procedurereturn @ReturnString
Froggerprogger
Enthusiast
Enthusiast
Posts: 423
Joined: Fri Apr 25, 2003 5:22 pm
Contact:

Post 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.
%1>>1+1*1/1-1!1|1&1<<$1=1
User avatar
Sveinung
Enthusiast
Enthusiast
Posts: 142
Joined: Tue Oct 07, 2003 11:03 am
Location: Bergen, Norway

Post by Sveinung »

Thank Froggerprogger!!!!

Worked fine!!!!

Sveinung
User avatar
Sveinung
Enthusiast
Enthusiast
Posts: 142
Joined: Tue Oct 07, 2003 11:03 am
Location: Bergen, Norway

Post by Sveinung »

AND GPI!!!!

Sveinung
Post Reply