LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Why not use globals?? instead of action engines or functional globals

Hi, ive had a look at action engines, functional globals etc. For transferring data from one parallel loop to another. But all i want to do is transfer data from one loop to another and a globals will do that. What benefit are these other styles??

0 Kudos
Message 1 of 4
(2,751 Views)

In certain situations globals can be ok. If you truly only write in ONE place, or if they are used to values that will never change; this will allow you to avoid race conditions. However, misuse can cause situations such as pushing the stop button but your program not stopping or one parallel loop getting different data than another parallel loop. I'm out of town so I can't post an example but please do a search of the forums. This exact question has come up multiple times.

0 Kudos
Message 2 of 4
(2,743 Views)

 


@stu22 wrote:

For transferring data from one parallel loop to another. But all i want to do is transfer data from one loop to another and a globals will do that.


 

Globals are needed of the two loops reside in different VIs. To transfer data between loops on the same diagram, all you need are locals variables. That's perfectly legitimate for simple cases.

Globals are more complicated because the require an extra external file.

 

Be aware of race conditions ...

 

Also have a look at queues and notifiers, for example. Sometimes they are better.

0 Kudos
Message 3 of 4
(2,738 Views)

There are no reasons not to USE local or globals, only reasons not to ABUSE them.  Unless you're absolutely certain you know the difference, it's best to avoid them.  Besides, the techniques you'll learn by using other methods can teach you a lot about passing data around in your programs.

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019
0 Kudos
Message 4 of 4
(2,705 Views)