LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Saving entered values as default in a .exe application

Solved!
Go to solution

I have a vi that monitors temperatures graphically using thermistors as sensors. I will be compiling this as an .exe application to use on multiple computers. I want to have a "settings tab" on the front panel that will have a number of numeric controls. The number entered into these numeric controls will be parameters of each thermistor and used to calculate the temperature. I am looking for a way to to save these values as default after they have been entered. The purpose of this is so that if a thermistor is replaced, the application can be configured with new parameters to match the thermistor.

0 Kudos
Message 1 of 10
(4,798 Views)

I have a roll-my-own set of VIs that store and read from XML. Basically just write a control cluster using the standard LabVIEW Write XML and then at program initialization do a Read from XML.

 

I'm pretty sure the MGI Library has the functions you want in the Application Control section if you want something pre-packaged.

Message 2 of 10
(4,782 Views)

You will need to save these values to a file before your program exits and read them back from the file when your program starts.

 

It does not have to be anything fancy like an XML file, a simple text file will work as you will save and read them back in the same order every time.

========================
=== Engineer Ambiguously ===
========================
Message 3 of 10
(4,777 Views)

OpenG also has a function in the Variant Config File menu called Read Panel from INI and Write Panel to INI. 

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 4 of 10
(4,764 Views)

Makes sense. What is the best way to have it read a file only one time when the program starts up and then assign the values to the correct spot? I cant think of a way to do it without reading continuously.

0 Kudos
Message 5 of 10
(4,759 Views)

Does your program have a defined structure, for instance a state machine, where you initialize your app and then transition to the main while loop and wait for some action to occur?  Is so, put the read in the initialize state.  

 

Loops are designed to do just that, they loop over and over until you tell them to stop.  If you don't want to read from the file continuously, move the read function outside the loop. 

 

What I suspect you are doing in this case is using the Run Continuously button to start your app.  This is a big no no.  You really should go look at the free resources that are offered by NI to learn Labview.    

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 6 of 10
(4,755 Views)
Solution
Accepted by topic author el_ManBearPig

Here's a simple example

 

When my program exits the last thing it does is save the front panel the settings by reading the local variables and saving it to a text file

SAveCapture.PNG

 

When my program starts the first thing it does is read the file (If it exists) and write the values to locals restoring the last settings

ReadCapture.PNG

 

========================
=== Engineer Ambiguously ===
========================
Message 7 of 10
(4,754 Views)

Ok this is good. But is there a way to have a numeric control on the front panel that displays the current value when the application starts without using a numeric indicator? basically I want a numeric control and indicator all in one that will display the current value and when a new value is entered and the app closed, will write values to a file. 

0 Kudos
Message 8 of 10
(4,714 Views)

I am not sure I understand your question, but a local variable will read or write to an indicator or control.

 

vCapture.PNG

========================
=== Engineer Ambiguously ===
========================
Message 9 of 10
(4,706 Views)

I recommend that you save your settings file whenever the user changes a parameter.

Only saving the file on program exit works fine if you always have an orderly shutdown of your program.

Does your IT department ever reboot your machines remotely (ie: after updates)?

Do you ever lose power in your building?

 

I'm sure you can think of other scenarios where your program is just stopped arbitrarily. 

Save your settings file on every change, minimize the chance of lost data. 

—Ben
Prevent your computer from sleeping programmatically!
Use Power Requests
Download from GitHub

0 Kudos
Message 10 of 10
(4,703 Views)