LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Where is pointer pointing to in Call Library Function

I am  using Call Library Function (FillString) to call a function in a DLL.  I set Parameter 1 to:
Parameter: arg1
Type: Array
Data Type: signed 32-bit Integer
Dimension : 1
Array Format: Array Data Pointer
 
so the Function Prototype below in the Call Library Function dialogbox is written as:
void FillString(long *arg1);
At the same time, in the block diagram , there is a "input param" (array of int32) and "output param" (array of int 32)
 
I wonder, when the program is in the DLL FillString function and using arg1 pointer, does "arg1" point to the data in "input param" arry or the data in "output param" array?  I don't quite understand, since normally C programs have only one return value, while the Call Library Function returns a value for every input parameter. Is the "output param" a different variable, or the same as "input param" (i.e., the same physical memory address)?
0 Kudos
Message 1 of 6
(2,782 Views)

Hi LyLee,

if your dll function only need the input and do not work on this data the output should be the same.

Mike

0 Kudos
Message 2 of 6
(2,781 Views)
Hi Mike,
 
Unfortunately, the DLL function has to modify the contents in the supplied char* arg1.  The idea is to provide a buffer to the DLL and let DLL write the output into arg1 array.  So, DLL will have to write to the memory address pointed by arg1, so I must make sure where it is pointing to.
0 Kudos
Message 3 of 6
(2,776 Views)

Hi LyLee,

if you know how many elements you need, create an array with this number of elements by using the "initialize array" function and connect it to your dll node. The output shall contain your data. If you have a string its the same. Create an empty string with the size you need. See the attached example picture.

Mike

0 Kudos
Message 4 of 6
(2,774 Views)

Hi Mike,

Thanks for the example. Still a question: why do you convert the array of integer to a string then supply it to DLL, instead of directly supplying the array to DLL?  Any difference?

Ly

0 Kudos
Message 5 of 6
(2,771 Views)

Hi LyLee,

sorry for the confusion, you can connect your array directly. The picture shows another example. This was the first i found at this moment. Smiley Happy

Mike

0 Kudos
Message 6 of 6
(2,765 Views)