LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

save and read control values

Solved!
Go to solution

I have a program that is heavily GUI intensive.

It has almost 100 string controls/combo boxes on the front panel.

Once the user fills out all the fields, I need to save all of the values into some file.

I don't care if the user can open/see/read the file, I just need LabVIEW to be able to read it.

Later on, the user is going to need to load this file and have all of the controls fill back in from the file.

 

From what I have seen by searching the boards,
I have heard a lot of suggestions like this one that say I should

bundle all of the controls together, then use XML functions to do the read/write.

 

I attached a very very simplified version of what the program's front panel looks like.

 

Do you agree with the above method? Or do you have a different way you prefer?

Cory K
0 Kudos
Message 1 of 15
(4,976 Views)

No need to do a lot of manual control. See this post (and read the rest of the discussion). Note, of course, that you can reverse the process by getting an array of references to all the controls and then removing the controls you don't want to save from that array.

 

I should also point out that the VI class has a Control Value.Get All and Set methods, but I wouldn't use them. In fact, OpenG has VIs to save and load panels to INI files which are based on this method.


___________________
Try to take over the world!
Message 2 of 15
(4,964 Views)

If you can bundle all of the string controls into a type-defined cluster control. You can use this control to write a binary file.  To read it back you can simply wire a constant derived from the type-defined cluster into the type terminal of the binary read VI and wire the output into an indicator. Viola! 

 

The disadvantage here is that the file is binary and thus challenging to inspect with a text editor.  Also if you change the content of your type-defined cluster, you will have trouble opening previously written files.  So that's were XML has some serious merit.

0 Kudos
Message 3 of 15
(4,919 Views)

Okay, after reading a whole bunch of threads, I sort of came up with something.

I used (roughly) a state-machine architecture to get through all of the tabs.

Then I used the Config example to write a config file.

 

The reason I chose to do this was the second half of the application.

I would like to take all of this data and enter it into a series of web pages.


All of the webpages are formatted with HTML Forms.

So I figured I would make the following associations:
Section Headings --> Form Name

Key --> Field Name

Value --> Value

 

This would make the transition easier.

Please run the attached example and let me know your thoughts.

* Note, it will create a folder in your C:\ drive called Config Files, within which it will create a file called Example.ini

Cory K
0 Kudos
Message 4 of 15
(4,903 Views)
Solution
Accepted by Cory_K

I would still try to automate it. Rather than manually processing each control, you can do something along these lines or modify my previous example:

 

22445i27993A48E60AC917

 

The big advantage is that you don't have to manually write code for every single control and that when you add controls it just keeps working. If the controls are not all strings, you can use the OpenG VIs to convert the variant to a human-readable string.


___________________
Try to take over the world!
Message 5 of 15
(4,893 Views)

Perfect, thanks a lot tst.

That should save me quite a bit of time.

Cory K
0 Kudos
Message 6 of 15
(4,881 Views)

Bonjour, 
Je sais que ce post est un peu ancien, mais j'ai un probléme sur un projet:
J'ai réussi à  écrire les valeurs de mes controls sur un fichier text mais l'affichage est un peu moche, j'aimerais pouvoir le changer mais j'ai aucune idée. Pourriez vous m'aider please?

Ngouda_0-1661525145478.png

 

0 Kudos
Message 7 of 15
(2,123 Views)

Hi ngouda,

 


@Ngouda wrote:

Hello, I know this post is a bit old, but I have a problem on a project: I managed to write the values ​​of my controls to a text file but the display is a bit ugly, I wish I could change it but I have no idea. Could you help me please?


Please define "a bit ugly"...

What do you have right now and what do you need?

Also keep in mind we cannot edit/debug/run images in LabVIEW so attach some real code!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 15
(2,105 Views)

Salut GerdW,
Merci pour votre réponse.

Vous avez raison. Je joins le fichier .txt que j'ai obtenu et le code .
J'aimerais avoir dans le fichier texte les valeurs sous cette forme:
Valeurs ID sauvegardées 29-août-22 09h36
TextInput_DriverLeft : WQDG1234 
Est ce que vous avez une idée ?
Download All
0 Kudos
Message 9 of 15
(2,072 Views)

Hi Ngouda,

 


@Ngouda wrote:
You are right. I am attaching the .txt file I got and the code.
I would like to have in the text file the values in this form:
ID values saved 29-Aug-22 09:36
TextInput_DriverLeft: WQDG1234
Do you have an idea?

Again you only attached an image instead of the real file, this time it is the "txt file"…

 

Yes, I have an idea: right now you read the control values as an array of variants.

When you want to store "just" the text without all that additional stuff of the variant you should read the control values as (array of) strings!

 

Right now I'm limited to LV2019, so it would be nice when you would attach a downconverted version of your VI (File->Save for previous)…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 15
(2,067 Views)