LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read/write array to ini file?

How can I reed/write arrays in to a ini file? I was trying to do it in a foor loop since the key.vi does not admit a input array. But only the last element is writen in to the file, how can I append new data in to a certain key?

 

 

 

keyini.png

0 Kudos
Message 1 of 11
(10,812 Views)

Each Key must have a unique name.

Otherwise the ini function will only (appear to ) write the last one.

 

 

The value in your case is a string

The keyname is also a string.

 

as in

keyname=value

 

0 Kudos
Message 2 of 11
(10,801 Views)

 

By the way

saving arrays to an ini file is probably not  a great idea, but this is only my opinion.

.

 

0 Kudos
Message 3 of 11
(10,799 Views)

Wich is the best way to keep save data to read it back on vi start up? I need to save state of my controls and indicators on shutdown.

0 Kudos
Message 4 of 11
(10,795 Views)

I ended up doing this:

 

keyinisprad.png

 

Using spreadsheet to list the array like: string1,string2,string3, and so on. I need to store a decent amount of data, idk if this will be a good idea.

0 Kudos
Message 5 of 11
(10,794 Views)

I have found these free VI's to be worth the effort to install them over the long haul.

 

 

http://mooregoodideas.com/readwrite-anything-vis/

0 Kudos
Message 6 of 11
(10,694 Views)

I think I would have just used the OpenG Read Panel From INI and Write Panel To INI functions.  They do all of the work for you, including saving of arrays and clusters.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 7 of 11
(10,782 Views)

Where could I find this?

0 Kudos
Message 8 of 11
(10,778 Views)

If you installed a recent version of LabVIEW, you should have the VI Package Manager (VIPM) installed.  If not, you can download it for free from jki.net.  Run it and let it search for Packages.  OpenG is about half-way down the list.

 

To comment on your original post, I've saved Channel information in a Configuration (.ini) file.  I had an array of 16 values, one per channel, and needed to make unique Keys.  I used the String Functions to create the (unique) keys "Channel00", "Channel01", etc. from the index of the For loop.

 

Bob Schor

0 Kudos
Message 9 of 11
(10,763 Views)

If you don't want to save the complete front panel with the OpenG functions, but just some of the some of the control, you could use the XML file functions in the File I/O/XML palette.

You can flatten the array to XML and save it to XML file. At program start you can read the file and unflatten it again.

If you want to save many controls, create a cluster including all the control types, and save the cluster as XML

0 Kudos
Message 10 of 11
(10,753 Views)