05-21-2016 01:29 AM
Can I intialise the default values of controls in a cluster to values read from a file whilst running the VI?
05-21-2016 01:38 AM
Right Click Control>Data Operation>make Current Value Default
05-21-2016 02:03 AM
05-21-2016
02:26 AM
- last edited on
03-28-2025
02:42 PM
by
Content Cleaner
What you are looking for is called configuration file. This is the way to save certain settings of an application, and when the user launches the app again, it looks for the file, loads data, and initialise controls or attributes (for example if the user changed Graph curve colours, etc).
I usually use OpenG configuration file VIs, see some discussions in this thread (also info about mutation --> when you change your typedef control, how you deal with old config files missing some new values of the cluster, etc...):
Edit: I also like the MGI addon, and it saves programming time: https://www.ni.com/en/support/downloads/tools-network/download.reusable-vi-library-for-labview.html
I attach an example I made some time ago how to use the MGI Save/Restore FP Data & Settings VIs:
05-21-2016 03:06 AM
When you play with my above example, you can find the created settings.ini file in your default data directory, in my case:
c:\Users\Andras\Documents\LabVIEW Data\settings.ini
You can open this ini file with a text editor (I prefer Notepad++), and change values in the file as needed.
[Data Values] MGI RWA Section Options=2.0.1 %04Y%02m%02d %02H%02M%S%25u*~|.%d*~|.;*~|.%#_13g stop=FALSE Save=FALSE Numeric=458 Numeric 2=4242 Numeric 3=4534 Numeric 4=52322 Boolean=FALSE Boolean 2=TRUE Cluster.Boolean=TRUE Cluster.String=blabla! Restore=FALSE XY Graph=<0>
05-23-2016 05:01 AM
The easiest built in way is to read/write an XML file.
/Y
05-23-2016 05:03 AM
05-23-2016 06:53 AM
@Blokk wrote:
But guess with the limitation of not handling cluster mutation well?
Not too well, no. I haven't tried it too much with mismatching clusters. That shouldn't be an issue in a deployed program anyhow.
/Y
05-23-2016 08:53 AM
The Save panel to INI, and Load panel From INI OpenG functions handle cluster mutation as best as you can expect. By that I mean it doesn't throw and error and will load all the things it can. It will then have an output stating if all things were found or only some. These functions are in the Variant Configuration package and works well as long as your data structures aren't loo large. Once you have arrays of clusters of arrays of clusters the load and save time can be a bit long.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord