LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

reading and writing control values to config file

I have been trying to make neat VI's to "automate" the saving of control values to a config file and reading them in from the file. It's been frustrating so far. I remember seeing a vi (LTR?, NI forum?)that did all that with great ease, but I can't find it anymore. Any suggestions?
It seems to me a pretty important tool in everybody's toolbox. Surely this problem has been tackled already.

Aart-Jan
0 Kudos
Message 1 of 16
(5,702 Views)
Hi,
Here is a couple of example that may help

http://sine.ni.com/apps/we/niepd_web_display.DISPLAY_EPD4?p_guid=B123AE0CBCEC111EE034080020E74861&p_node=DZ52074&p_submitted=N&p_rank=&p_answer=&p_source=External

http://sine.ni.com/apps/we/niepd_web_display.display_epd4?p_guid=B45EACE3DACB56A4E034080020E74861&p_node=DZ52027&p_source=external

If not attach your VI.

Regards
Ray Farmer
Regards
Ray Farmer
0 Kudos
Message 2 of 16
(5,702 Views)
I work with LabVIEW 6.1.
To save the values of controls, strings etc. I use the vi's of the config.llb. Normally you find the llb under ...\LabVIEW 6.1\vi.lib\Utility\config.llb.

To write to the ini you have to take the vi's in follow order: "Open Config Data.vi", "Write Key.vi" (your data) and "Close Config Date.vi".

To read from the ini take: "Open Config Data.vi", "Read Key.vi" (your data) and "Close Config Date.vi".

Please write a message when you need an example-vi.
0 Kudos
Message 3 of 16
(5,702 Views)
Sorry, I was probably not clear enough in my question. I know about the config Vi's. The problem I am trying to tackle is to have a lot of controls and when I press save, I want to have the VI read all controls and write them to the ini file. Similarly I want the VI to read al the values from the file and populate the controls.
Granted it can be done with the config vi's, but it gets bulky and cumbersome. The other alternative I found was to flatten to xml and write to an xml file and vice versa.
What I am really looking for is a way to programmatically cycle trough all the controls in the vi and collect say their label text and values into a 2d array and write that array to file using the ini file or xml file.
Something like this would also be nice:
Fo
r every control
flatten to xml
or: extract label text & value
write key
close config file

It would save a LOT of code.
I can imagine that a subvi can do it for it's parent vi..
Maybe I am completely on the wrong track here..

Aart-Jan
0 Kudos
Message 4 of 16
(5,702 Views)
Hi Aartjan,

I know that this involves a lot of coding. Please take a look at the VI attached in the following document. If you decide to take the route of config VIs, I think it will be a good starting point:

How Do I Change Default Values In A LabVIEW Executable?

I hope this helps.

Sincerely,
Feroz
National Instruments
Message 5 of 16
(5,702 Views)
these links have pretty useful stuff, albeit not for what I am trying to do. I explained it into more detail below.
thanks Ray.

Aart-Jan
0 Kudos
Message 6 of 16
(5,702 Views)
Thanks Feroz, it does what I need in functunality, but is exactly not the way I want to tackle this problem.
For instance: how are you ever going to reuse such code?
I am trying to make components that I can add to my user toolbox, meaning it needs to be easily scalable and "generic." As I was spending incredible amounts of time on this problem I realized that many most have tackled this problem allready in a much more effecient way.

I have allready come a ways, but it would really help if there is a way to programmatically list all the controls in a vi.

I really appreciate all the support, everybody..

Aart-Jan
0 Kudos
Message 7 of 16
(5,702 Views)
Jean_Pierre has done this work already!

Follow this link to your solution.

http://exchange.ni.com/servlet/ProcessRequest?RHIVEID=101&RPAGEID=135&HOID=506500000008000000265A0000&UCATEGORY_0=_49_%24_6_&UCATEGORY_S=0&USEARCHCONTEXT_QUESTION_0=Jean-Pierre+config&USEARCHCONTEXT_QUESTION_S=0

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 8 of 16
(5,702 Views)
What really makes his code cool is that it chases down nested objects.

Things like clusters in arrays in cluster in tab controls in other tab controls...etc.

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 9 of 16
(5,702 Views)
Fantastic! This was exactly what I was looking for.
The example I included below came from this discussion page at openG (I hope that is not a problem..).
Although haven't analyzed the vi's at all, the magic difference seems to be that the tab control actually has a property called "controls on page[]." As soon as you have an array of control references it is easy to loop any control property into an ini file. As long as all controls you want to save are on tab pages, they are programatically accesible.
Thanks a lot Ben!

BTW. I was not able to install the toolkit because I allready use 7.1, but because I found this VI, I still got the tools I need.

Aart-Jan
Message 10 of 16
(5,702 Views)