LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how get array from dll delphi

Hi everybody,

 

I have a problem using array and dll which I did using Delphi.

My question is simple : how can I get an array from my dll ?

 

I don't understand because I tried a pointer of an array of double and an array of pointers of double. Those two don't work.

 

here are my parameters for the Call Library function

Name : arg1

Type : Array

Constant : false

Data type : 8-byte Double

Dimensions : 1

Array format : Array Data Pointer

Minimum size : 2

 

and my code Delphi :

procedure fonction1(var References : PTabTest);stdcall;
var
  indx: integer;
begin
  New(References);
  SetLength(References^,3);
  References^[1] := 0;
  for indx := 0 to 3-1 do
  begin
    References^[indx] := indx+0.5;
  end;
end;

procedure fonction2(var References : TTabTest2);stdcall;

var
  indx: integer;
begin
  SetLength(References,3);
  for indx := 0 to 3-1 do
  begin
    new(References[indx]);
    References[indx]^ := indx+0.6;
  end;
end;

 

I've search on the forum without success (even if a lot of people wrote on it).

In my file attached are my vi where I'd like to get my array, the code to create the dll and the dll compiled.

 

Thanks a lot for your help

 

Fabrice

0 Kudos
Message 1 of 4
(4,879 Views)

Hello Fabrice,

 

What is your DLL format ? Would you be able to have a C/C++ DLL ?

 

Which version of LabVIEW are you using ?

 

Just to let you know, we don't have DELPHI here... but I will try my best to help.

 

Regards,

 

Yannick.

 

PS : did you have a look on this ? If you have a DAQmx board, would be ableto call those DLL just for testing ?

http://forums.ni.com/t5/Digital-I-O/Are-there-Delphi-examples/m-p/897513?requireLogin=False

0 Kudos
Message 2 of 4
(4,862 Views)

Hi Yann,

 

Thank you for your answer, I'm using Delphi 2010 and LV 2010. In fact I succeed to get an array!

Here is the code of my dll (sadly I have to do it using Delphi...) :

 

procedure transTableau(var T : Double;taille : integer);stdcall;export;

type
     TTabMat = array[0..10] of double;
    PTabMat = ^TTabMat;

var
    i : integer;
    pMat : PTabMat;

begin
  pMat := @T;


  for i:=0 to taille-1 do
  begin
    pMat^[i] := pMat^[i] + i;
  end;

end;

 

The LV code is the same as previously, just I had the size of the array as parameter.

 

The thing that I was doing wrong (to use my dll with LV) was :  trying to pass the array or a pointer on the array instead of passing just a pointer on the first value of the array.

The only thing that is missing is to use a dynamic array in my dll (if someone have a solution that works... but maybe the question should be asked on a Delphi forum)

 

I hope this could already help someone.

 

Fabrice

0 Kudos
Message 3 of 4
(4,853 Views)

use variants to pass data...the variant can store the array and most of LabVIEW data are internally variants and can be converted to it.  We use delphi/labview in our project and that is how we pass data back and forth.

 

G.

0 Kudos
Message 4 of 4
(4,638 Views)