11-27-2014 06:39 AM
There are some posts to this topic, but I couldn't find a satisfying solution to this.
Simply example for what I am looking for a solution: The fronpanel includes one numeric input element. I start the VI, change the value of the numeric input element to an other value and than stop the VI. The next time I start the VI I want the numeric element to have the value that it had when the VI was stoped. Preferably, I want the value of the numeric element be setted up as "standard-value" when I push a button (see the example attached).
Thanks.
Solved! Go to Solution.
11-27-2014 07:04 AM - edited 11-27-2014 07:07 AM
If you build an exe from a VI, the actual default value of a numeric control (or any other entity) cannot be changed any more. This is not LabView specific behaviour actually, how do you want your program (the exe file) to change itself? 🙂
But there is an easy workaround for this, you can use configuration files. There are many examples, you can use csv, xml, ini, and many other file types and methods.
A possible way to do this: when the user closes the applications, you take the actual value of the control, and save this value to a config file. When the user runs the exe again, the program loads the config file, and changes the default value of the control into the value which was stored in the file.
Of course you can make config file read/write even optional, with multiple configuration files...Just think about other programs which we use daily: they work in the same way...
11-27-2014 07:05 AM
The MGI Toolkit (free, available in VI Package Manager) has VIs for 'Save Front Panel to INI File' and 'Load Front Panel from INI File' functions - when called it will write the state of the front panel to a file and then you can load the values from this file again at launch.
If you don't want to save all of the controls/indicators, you can do it yourself by writing the values to a file yourself. Have your VI try to read the values from a file and have an event structure for your 'save' button which gets the values of the controls you want to save and writes them to a file.
One way to do this would be to create/get references to the controls you want to save and using a property node to get the 'Label' and 'Value' properties which you can write to the file.
11-27-2014 07:54 AM
I put together a very basic example, which should give you the idea. Find it attached (this subVI only works with doubles).
Of course the toolkits which Sam_Sharp mentioned are much more "pro" solutions with much more options...
Regards!
11-27-2014 08:00 AM
hmm, out of edit time 🙂
I have attached a bit different mainVI which is closer to what you want I beleive...
Regards,
11-27-2014 08:15 AM
Thanks, that is exactly what I was looking for.
11-27-2014 08:17 AM
A good example Blokk, you can modify it to work with any control with something like the following:
(Obviously you need to sort out the errors and references, open/close the config file, wrap it up into a SubVI, error handling etc.)
11-27-2014 08:21 AM
yep, this is the pro solution, more universal...