LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW Array in Delphi DLL

Hi everyone.

I am in the process of creating a "ATE" application using LabVIEW 7.1 and Teststand 3.1. It has all been pertty much "smooth sailing" up till now. 😞
One of the VI's captures a graph from a Network Analyzer through a GPIB interface. The data is returned in the from of an Array of Clusters. Each of these Clusters then contains two double values.
Array
    (Cluster)
          (double)
          (double)
This information needs to be stored into a BLOB (Binary Large Object) field in a Firebird database. Since there are no drivers for Teststand or LabVIEW to connect to the Firebird DB directly I have to use ODBC drivers. But, I still cannot store Binary data to the database. I then decided to write a Delphi DLL, the only language available to me at this stage, to insert the data into the Firebird DB.

Code snippets:
[Delphi]
..
...
  Type
    TGraphCluster = Record
        real_stim: double;
        imag_resp: double;
      end;
  TGraphClusterArray = Array[0..200] of TGraphCluster;
  PGraphClusterArray = ^TGraphClusterArray;
 
  Function StoreArrayIntoDB(Val: PGraphClusterArray): integer; stdcall;

implementation

Function StoreArrayIntoDB(Val: PGraphClusterArray): integer; stdcall;
begin
  result := -2;
  try
    result := val^[7]; //element 7 is used as an example
  except
    result := -1;
  end;
end;

This piece of code serves as an example...Obviously. Now, if I can manage to get this function to return the value of any array element using the "Call Library Function Node" in LabVIEW, I'll be verry happy. :-).

In LabVIEW I pass the array as an "Array Data Pointer". In actual fact, I have tried all of the "Array Formats". It might also be worth mentioning that I tried to pass a "less" coplex array, array of double to the delphi DLL, but with no avail.

Any suggestions welcome. 🙂
0 Kudos
Message 1 of 4
(3,938 Views)
Hi WikusJacobsz-
 
I would recommend first reading Chapter 2 of the Using External Code in LabVIEW manual and walking through the Troubleshooting Checklist on page 2-34.  Most likely this will help you isolate the source of your problems.
 
The following discussion forums also specifically address Delphi DLL issues:
 
Hope this helps!
Drew Pierce | District Manager, Central Texas | National Instruments
0 Kudos
Message 2 of 4
(3,915 Views)
Ok, backup a minute. You don't need an external DLL to write blobs to Firebird. Assuming a table with the definition:

CREATE TABLE blob_test
(   id_column   INTEGER,
    data_struc  BLOB
);

The attached code will insert and extract BLOB data. The key is to realize that you don't insert blobs the way you do most datatypes - though it can be read out exactly the same as you would any other value, you just have to unflatten it to turn it back into a LV datastructure. In the example, the data structure I inserted was a LV error cluster, but it could have been anything of any size. Just wire-up your data-structure of choice to the flatten to string...

Also in my own work I have these broken up into subVIs that I can send you if you want. I "unpackaged" it out here so you can see the inner workings easier.

Mike...

Message Edited by mikeporter on 06-03-2007 12:43 AM


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Download All
0 Kudos
Message 3 of 4
(3,904 Views)
Opps, just noticed that you are working in LV7.1. Here are the VIs in that version.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Download All
0 Kudos
Message 4 of 4
(3,896 Views)