LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Nested clusters and array controls: exporting to INI files

Solved!
Go to solution

hi,

 

I am currently working on redefining our methods for storing control values to ini files.

The way we go about it now is we read all VI panel controls and filter them by neccessity of storing (by using label text).
The downside of this is that each topmost cluster or array is stored only (all contained controls are part of the stored value).

 

This is mostly an issue when between versions of our executables the content (number and type of controls) of these clusters and arrays change.

 

I did some exploratory work with the OpenG library and found some solutions ot this by checking if the control is a cluster or an indexed cluster (an array containing clusters) looping through all the values needed to write and writing them to the element with the same label text.

This enables the storage to be more robust as it does not break everytime we add controls etc.

However, I ran into cases where we have deeper nested clusters (an array of clusters which themselves contain clusters again).
how do I create a sort of recursion for detecting the bottom most "child" within these nested clusters and work my way up from them to the top array?

 

See the screenshot below  for the "exploratory" data reformatting methods I came up with:

cluster readwrite.pngindexed cluster read write.png

for clarity, the problem arrised when I make a change in the deepest cluster of array 2 or array 3. This will result in the complete array not being written.

The solution is to implement another check for data typing and add the top solution for writing clusters, but how do I make this more recursive to solve any future cases of deeper nesting?

0 Kudos
Message 1 of 5
(1,733 Views)

If I understand correclty, you can use a While Loop and a shift register with the ClassName and loop trough it until there is no Array or cluster

=======
My Channel: https://www.youtube.com/@LV_Lab

0 Kudos
Message 2 of 5
(1,714 Views)
Solution
Accepted by topic author Rubenske1

I would recommend getting away for INI files since they do not do well for embedded data.  I would use JD Powell's JSONtext library to save the data to a JSON file.  JSON is a lot easier to understand when you start dealing with clusters, arrays, arrays of clusters, etc.  And that library works wonderfully, even if the cluster has changed definitions between your versions.


GCentral
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 3 of 5
(1,689 Views)
Solution
Accepted by topic author Rubenske1

For such nested complex data structures, XML or JSON are better suited than INI files.

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 4 of 5
(1,682 Views)
Solution
Accepted by topic author Rubenske1

I understand that JSON is an easier to read format.
Unfortunately, we do not want it to be human readable (due to customers being able to modify controls that they normally dont have access to).

 

I did some further digging yesterday and deviced a new method that still writes to INI files, but is able to check data for deviations and act accordingly (non-destructive) by using the JKI "Adapt to Type" VI.

 

I will share the code piece below for future reference:

new VI completelynew VI completelywrite case of VIwrite case of VI

if people are interested in this method, please let me know and I'll upload it.

0 Kudos
Message 5 of 5
(1,672 Views)