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: 

Need advice with saving and loading configuration files.

Hello,

 

When developing applications I want to make it possible for the user to save the current configuration.

The configuration being the values of the control- and the display elements of the frontpanel, aswell as

internal variables.

 

If the user loads the configuration file all frontpanel elements and internal variables should be updated.

 

("Nice to have" would be if the configuration files are ASCII based, so they can be edited with an text editor

like notepad. The file would have a legend/header so people can easily see what every value represents.)  

 

The problem I have is programming this in a nice, clean and scalable fashion.

 

Methods I tried:

 

- Using "Format Into String" function

This is tedious and dirty. Making local variables off all elements on the frontpanel, reading all data from FGV.

Taking clusters apart to every single value to convert them into strings. Sometimes not knowing how long

arrays will be. And after loading the file making sure every value is wired to the right frontpanel element.

Then a software revision comes up and you need to remove and change some elements.

"Old" configuration files are not compatible with the new revision anymore, users are not happy.

 

- Using "Flatten To String" function

Still tedious, but this has the possibility of using a loop with case structure. Less clutter on the blockpanel.

Clusters can be saved as a whole. But the configuration files are not editable with an text editor and reading

the text from the file is difficult (sometimes impossible) because you do not always know where each value

starts and stops, especially with clusters and arrays.

 

 

I hope you don't think I'm whining Smiley Surprised

 

So, how do you guys go about making configuration files for your VI's?

Kudos will be given! Smiley Happy

 

--------------------------------
The Enrichment Center is required to remind you that you will be baked, and then there will be cake.

0 Kudos
Message 1 of 3
(2,063 Views)

There are many examples available online. This is one which is useful for UIs - https://decibel.ni.com/content/docs/DOC-15349

 

You will note that the comments there also mention OpenG VIs. Those are the variant configuration VIs which allow you to save and load an arbitrary cluster to an ASCII file (and they load correctly if you modify the cluster). MGI also has a set of similar VIs.


___________________
Try to take over the world!
Message 2 of 3
(2,056 Views)

There was a presentation at a LabVIEW Users Group here in Oregon in February about how XML files may be used for this purpose.  Take a look:

 

https://decibel.ni.com/content/docs/DOC-26776

 

Jeff

Jeffrey Zola
0 Kudos
Message 3 of 3
(2,023 Views)