LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a way to store state of dynamically loaded vi without resorting to subvi tricks?

Solved!
Go to solution

I have a VI for opening a UDP connection, retrieving data, and then closing the connection:

 

callout1.png

 

Setting state to 1 opens a UDP connection.

 

callout2.png

 

Setting state to 2 retrieves a UDP package. Most boxes above is for data manipulation.

 

callout3.png

 

Setting state to 3 closes the UDP connection.

 

Now, calling this vi as a subvi works just fine:

 

test_working.png 

 

But, calling the vi dynamically doesn't:

 

test_not_working.png 

 

The second call inside the while loop raises an error. Apparently, referenses are not valid from one call to the next when calling a dynamically loaded vi. What I need to know is, is there a convenient way around this?

 

Lars Melander
Uppsala Database Laboratory, Uppsala University
0 Kudos
Message 1 of 3
(957 Views)
Solution
Accepted by topic author LarsM

Hello,

 

Calling dynamically a VI inside a while loop may be pretty bad in terms of performance and I'm not sure that's a good idea.

 

But if you really want to do this, using "Call by Reference Node" function should be more appropriate in your case (you will find some example easily).

 

Best,

 

J.

Message 2 of 3
(951 Views)

Worked perfectly, thank you.

 

> Calling dynamically a VI inside a while loop may be pretty bad in terms of performance and I'm not sure that's a good idea.

 

Making the dynamic vi reentrant makes performance decent. 

Lars Melander
Uppsala Database Laboratory, Uppsala University
0 Kudos
Message 3 of 3
(936 Views)