LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

passing a reference in to a dll

Let's say I have a DLL function that I need to call in LabVIEW, and in C the code would look like:

 

unsinged long               input1;

unsinged long               input2;

 

testfunction(&input1, input2);

 

 

It is easy to do the opposite of:

 

testfuntion(*input1, input2);

 

 

Any quick suggestions or places to look?

 

Edit:  This is for a simple DLL Library call. And for clarity, what the function is expecting is a memory address.

0 Kudos
Message 1 of 6
(3,787 Views)

Have you looked at the Call Library Function Node configuration dialog box? There's an option to pass a value by pointer.

0 Kudos
Message 2 of 6
(3,775 Views)

I have. Unfortunately, I need to pass a reference in, not a pointer.  Ideally it would be the memory address of a control so that the function could change the value.

0 Kudos
Message 3 of 6
(3,764 Views)

A reference to a value and a pointer to a value are exactly the same thing in C. And the Call Library Interface uses C logic.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 4 of 6
(3,762 Views)

It would appear there is a lack in my understanding.  In C the function will take the address and change the value there to be used in later function calls. The "real" code is for an IVI/VXI Visa driver that I'm having issues with.  Basically in C, the code is:

 

unsigned long     session;

 

init("VXI0::9::INST::",&session);

 

setchannels(session,1);

getdata(session);

... etc.

 

In this case the init function just changed the value of the memory address at session, and then that variable is just fed in to every other function.

0 Kudos
Message 5 of 6
(3,756 Views)

When you configure the Call Library Function Node, you will configure the "init" function to pass the session parameter by pointer. The function will receive a pointer (or reference) to the memory address of that wire, and will update it with the new session value. The output side of that parameter will be the session value, which you can then pass by value to the following functions.

 

It looks just like it does in C. You configure the "init" function for the session parameter to be passed by pointer, and then you take the corresponding output and pass it by value to the other functions.

0 Kudos
Message 6 of 6
(3,753 Views)