From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Loading Preferences In an Executable

Hi all,

     Using LabVIEW and Application Builder 7.1 here. One thing I miss is the ability to tell the VI to remember the default values for my front panel objects. My solution to get around this is to write a config file and read the config file at the beginning of the VI and then pass the values from the config file to the variables and then write any changes at the end of the VI's execution pattern. Now what I also want to do is to have some variables accessible from a "Preferences" window that pops up  similair to most applications. This is very easy to do, but once again this variables lose their values and need to be loaded for disk. A third hurdle is some of my SubVIs are 4 or 5 VIs deep and they need access to variables at the top level, so passing through all those layers to pass data becomes very messy. My solution was to use a global variable and when the Main starts it will load the config values and write them to the global variable to give every VI access, I'm passing fairly constant data, such as COM ports and such, so I think I'm avoiding the bad programming practices that come into play with Global VIs. Now my problem is I have to have a segment of code for each variable reading, then passing it to the variable in LabVIEW, then writing it at the end. So that's 3 segments of code for each variable I wish to preserve through the config file. Is there an easier way of doing this?

Regards,
Ken
0 Kudos
Message 1 of 2
(2,277 Views)
Hey ken,
So what if you start your program and read all of your front panel values into a functional global. There would be one shift register for each value, or you could consider using a single cluster containing all of your values in a shift register. Once you read the data into your functional global, you can call that global anywhere in your code and only retrieve \ set those pieces of information you're interested it. When you're program ends, simply have a "write to file" state for your functional global in which you write all of yoru values to your ini file. If you're not familiar with the idea of a functional Global, check out our Global Variables example. Post to let us know if this helps!
 
Chris C
0 Kudos
Message 2 of 2
(2,247 Views)