02-19-2013 01:53 PM
I'm trying to share a cluster across several sub .vis. I've written a save / load settings function that basically stores these settings in a static variable (full .vi attached):
Questions:
1. Is this an appropriate practice? (using a sub vi to share data)
2. My program settings appear to be lost occasionally and reset to their default values. This bug is rare, and it's hard to see what's causing it. Could this be caused by my "save / load settings"? Would this .vi result in race conditions or something weird if I use it in many places (and sub vis)? I've disabled reentrant execution.
The "save / load settings" vi above uses a sub vi to initially read the settings from a binary file and save them each time they are changed (saved). I initialize the "save / load settings" by loading the settings from text the first time this function is called.
Thanks!
02-19-2013 02:45 PM
What you are doing is generally called a LabVIEW 2 Style Global or an Action Engine. It is a valid way to store data for use across subVIs. Rather than use first call why not have a specific action to initialize the data? The code is a bit more readable. Though you can use first call as you have.
02-19-2013 07:57 PM
Thanks Mark, any chance this function is causing my sporadic resets (the cluster is reset to the default value)?
If not I guess I can look at the data I'm sending to the function when it saves...
02-20-2013 04:18 AM
A reset is expected if you pass "Load Settings" or an invalid option as "Mode" and "First Call" as "True". Otherwise, the data should only reset if you unload the VI inbetween.
So you should first off focus on mis-parametered (does this word exist???) calls.
Norbert