LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problems understanding global variable access with SubVIs called by reference

Hi,

I still have some problems with globals:
My application uses a state machine that calls several VIs with "Call by Reference" nodes.
One called VI acts as configuration, global variables are written.
Other VIs that are called in other states of the states machine read from the globals.

I faced the problem that sometimes my global still held the default values although they should have been changed by the configuration VI.

My question:
Are globals kept in memory, when they're only accessed by VIs that are called by reference?
If not, could I make them do their job by using them once in the state machine architecture?

Thanks and best regards,

Andreas
0 Kudos
Message 1 of 4
(2,906 Views)
Use functional globals and make sure there's always a reference to them open.
0 Kudos
Message 2 of 4
(2,906 Views)
I know this alternative, but as race conditions are not crucial, I'd like to try it with "normal" globals first (easier handling of 30 strings).
Is using the globals' VI in my main state machine comparable with keeping a reference to them open?

Regards,
Andreas
0 Kudos
Message 3 of 4
(2,906 Views)
If you call the globals VI statically (instead of by reference) things should be fine. If you call it by reference just make sure the reference is kept open as long as it's necessary.

A functional global would be simple to use no matter how many strings you have. You won't have the right-click possibilities of standard globals but still...

Race conditions is one thing, memory usage and speed are other (and often more significant)reasons to choose a functional global instead. The possibility to add other methods than read and write to the functional global is another handy thing.
0 Kudos
Message 4 of 4
(2,906 Views)