Page 1 of 1

Dll and array

Posted: Mon Jan 01, 2024 12:23 am
by spacebuddy
Hello All,

Is there anyway in Purebasic to pass an array using a Dll?

What I want to do is create the DLL in Purebasic and pass an array of string to another programming language.

Thanks

Re: Dll and array

Posted: Mon Jan 01, 2024 10:04 pm
by AndyMK
Something like this maybe? This code is not checked so might not work.

Code: Select all

ProcedureDLL AttachProcess(Instance)
  
  Global Dim my_string_array.s(10)
  
EndProcedure

ProcedureDLL DetachProcess(Instance)
  
  FreeArray(my_string_array())
  
EndProcedure

ProcedureCDLL array_of_strings()
  
  my_string_array(0) = "hello"
  my_string_array(1) = "world"
  my_string_array(2) = "DLL"
  
  ProcedureReturn my_string_array()
  
EndProcedure
It depends on what your other language is. You could also use structure arrays which is more like C