LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to save user setting

I'm doing some planning for a new project and need to figure out the best way to allow the user to save there preferences and settings.  The main VI be used for troubleshooting equipment and the operator will be able to choose which sequence of test they want to run.  I would like to be able to save the user specific prefference for each piece of equipment they are testing to some kind of prefference file.  I have written data to text and spreadsheets before but didn't know if there was a better way to save user preferences than simply writing plan text to a text file.  Any suggestions as to a perfered method for saving user preferences and settins?

 

Thank you

 

Danny
0 Kudos
Message 1 of 5
(4,053 Views)

Hello Danny,

 

You should use .ini file.

https://www.ni.com/docs/en-US/bundle/labview/page/configuration-files.html

 

And you should download Open G library they devellopt an amasing API wich allow you to directly write and read cluster into ini files.

 

Sabri JATLAOUI - Certified LabVIEW Architect - Certified LabVIEW Developer
Message 2 of 5
(4,042 Views)

I prefer to use XML for things like this as parsing it is simpiler, but really the file format does not matter.

 

You just have to save all your controls to a file and be able to read that back and restore them next time.

 

The file coud be as simple as a comma seperated values (.csv) text file as long as you save and restore them in the same order.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 3 of 5
(4,009 Views)

There is a caveat using XML file instead of .ini.

If you're changing your main cluster, you can't read old file.

With the .ini each element is define by key and sections. If an element is add or remove from the file, you still can read it with the same API.

 

dannyjhu there is a code example already developed.

https://knowledge.ni.com/KnowledgeArticleDetails?id=kA03q000000YILZCA4&l=en-US

 

Good luck.

Sabri JATLAOUI - Certified LabVIEW Architect - Certified LabVIEW Developer
0 Kudos
Message 4 of 5
(3,980 Views)

@sabri.jatlaoui wrote:

There is a caveat using XML file instead of .ini.

If you're changing your main cluster, you can't read old file.

 


This is not true, I have been maintaining a program for almost a decade that uses XML for configuration. I have added and removed sections of the cluster that is populated from reading the XML file more than once. 

 

Sure the new version of the program will not run properly with an old XML file because there is missing information unless the XML config file was also updated. That will happen regardless of what file format you store your configuration.

 

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 5 of 5
(130 Views)