01-10-2011 12:59 PM - edited 01-10-2011 01:00 PM
For something like that you can either use LabVIEW to save the binary data which can be read back correctly, use "flatten to string" to save the data, or device your own format (such as a CSV file) if you need to allow the data to be viewed or modified outside of LabVIEW.
The correct answer will really depend on what you want/need to do with it.
01-10-2011 02:56 PM
Here is an example of how I do this. I use flatten to xml but as Mark points out you can flatten to string instead.
It is more convenient if you can create a typedef cluster containing the controls you want to set the default for.
01-10-2011 03:56 PM - edited 01-10-2011 03:59 PM
Hi Steve
thanks a lot for your answer! but I want to create multiple clusters of the same element type. 1 universal save button could save all the values in the cluster.
How do I get around this? I tried to create the correct VI but seem to be stuck.
Thanks again for your answer!
mhaque
01-10-2011 04:06 PM
You might consider using a separate file for each cluster.
01-10-2011 04:14 PM
@SteveChandler wrote:
You might consider using a separate file for each cluster.
Or store them as an array of clusters. Though this would require creating the array on the fly when the user saves the data. The typedef was not included in the last posted code so when I opened it it was broken but are you using a separate control for each tab? One way to use an array internally but display the correct value on the tab would be to use a single control representing one set of data. This control is configured to be common for all the tabs. Internally in a shift register you have an array of the controls. This can easily be intialized from the file since the entire array would be read from the file. Same holds tru for writing in. On the UI when you switch the tab you simply set the the value for the display control to the corresponding position of the array data.
01-10-2011 04:55 PM
Doesn't work if I want to unbundle the array into its separate elements. Only steps and Stop Timer shows but the matrix is nowhere to be seen?
Thanks for all your help!
mhaque
01-10-2011 05:07 PM
I made the vi just save all the controls on the front panel. It will work if you remove some or add some.
I had to remove the tab control and use an array. The controls in the tabs were not being saved. I think this is because I am getting the Controls[] property for the front panel and it didn't include controls that were placed on the tab panel.
01-10-2011 05:12 PM
wow amazing, but could I label the indexes of each array as A1, A2, A3... rather than 1, 2, 3 wihtout making the code too complicated?
Thanks a million!
mhaque
01-10-2011 05:23 PM
No problem. One thing you can do is to hide the index and select the index from an enum.
01-10-2011 05:28 PM - edited 01-10-2011 05:31 PM
Here is an example of what I was suggesting earlier. This example uses a Tab control like your original post but saves the data as an array. You can initialize the array from the file when you start the application as well.