LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Duplicate sub vi with the same global variable

This is a simple question, that probably was answered before:
I had a sub vi that uses a global variable. Now I need two of these sub vi's working simultaneously in a while loop. The problem is that they are both adressing the same global variable, but I need them to be isolated. How do I do that?
Thank you.
0 Kudos
Message 1 of 3
(2,717 Views)

Hi Ivan,

global variables are not the best way to solve this problem, because they can produce race conditions. A better way could be to use a "global functional variable". Its a sub vi which stores your data.

Mike

0 Kudos
Message 2 of 3
(2,715 Views)

Hi Ivan,

This Developer Zone article explains a little more background about why functional global variables are the best option for you. Happy coding!

Amanda Howard
Americas Services and Support Recruiting Manager
National Instruments
0 Kudos
Message 3 of 3
(2,684 Views)