‎08-10-2010 10:31 AM
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??
‎08-10-2010 10:45 AM
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.
‎08-10-2010 10:53 AM - edited ‎08-10-2010 10:57 AM
@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.
‎08-10-2010 01:29 PM
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.