LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Store state of tree control to file

What is the best way to store the state of a tree control to file, assuming I want to retrieve the state later?  How can I store it in such a way that all items and the hierarchy is preserved?

Message 1 of 3
(2,423 Views)

Kudos for the good question. I too would like to see a streamlined solution for reading and writing from/to a tree. It takes several property nodes and invoke nodes.

 

MooreGoodIdeas.com has a VI called Populate Tree with Delimited Strings.vi. That should populate your tree, so saving it to file should be as simple as writing to a spreadsheet file, but it isn't. You have to save the indents and symbols, etc.

 

The LAVA site used to have a good set of tools for trees. Google LAVA labview.

 

I hope that VI gives you some ideas, and hoping some tree experts can chime in. In the mean time, "the trees are all kept equal..."

 

Richard






0 Kudos
Message 2 of 3
(2,406 Views)

In the absence of a canned solution to this problem, all I can think up is the following:

 

1.)  Create an LVOOP class to be used for all tree functions

2.)  Member variables for the LVOOP class should be a tree refnum and an array of clusters of tree item properties (indents, expanded, child-only, symbols, etc.)

3.)  Save the LVOOP object to file and use its data to repopulate the tree control on load

 

Then you have two implementation options.  If a tree control will always be present, you can use the tree control methods for editing the tree and be sure to store the full state of the tree to the LVOOP object each time something is changed.  If you're dealing with multiple tree hierarchies that aren't always associated with a tree control, you'd have to replicate the tree control methods as part of the LVOOP class.  This would allow you to work with any number of trees; merging, sorting, storing to file and retrieving, etc. and then displaying them in a tree control whenever you see fit.

 

There needs to be an abstract "tree" concept that is a data structure (like an array) that is independent of a GUI control.

0 Kudos
Message 3 of 3
(2,391 Views)