LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Saving and loading controls

I'm looking for a way to save my control values to a file and load them later so users can quickly setup the VI the way they want it.  I have no problem saving/loading some basic controls like strings, numbers, booleans, etc.  My problem is with saving list boxes or rings.

Take a look at my sample program.  You can add items to the listbox by selecting an item from the ring and pressing the add button.  Then save by pressing the "Save" button.  Clear the list box by pressing "Clear", and then try to load in the old values by pressing "Load".  You'll see that the strings from the listbox don't get saved away.

Is there a simple method for saving this information?  One option that I've considered is using the "Get All Control Values" method and then examine the type descriptors to see what type of control it is.  If it's a listbox or ring, I can use the property nodes to save the strings.  I was kind of hoping there was an easier, more straight forward way to do this.

Any suggestions?


0 Kudos
Message 1 of 10
(3,705 Views)

Hi,

The elements of a list are not available through it's value, but through a property called ItemNames witch is an array of strings. That's why when you save the control values, you don't get back the list items.

The value of the list is the index of the selected element.

So, in this case, to recover the item names of teh list, you have to save the property item names to a file, otherwise you get the value of the control - the index of the selected value.

Paulo

0 Kudos
Message 2 of 10
(3,700 Views)
Yes, I understand why it doesn't save the strings, but is there a simple way for saving them or is the method I outlined above the best way to do it?  I'd like to use the Get All Controls method, because I don't want to explicitly create a property node for each listbox I want to save (there's too many, plus a maintainance issue).  Is it possible for me to get the properties of an object with the information I get from Get All Controls?


0 Kudos
Message 3 of 10
(3,697 Views)
Your suggestion sounds like the only plausible way to do this, but to get the values, you will have to get the reference first, which you can't do with Get Controls Values. To get the reference to all the controls, it is not enough to use the VI's Controls[ ] property, because that doesn't give you controls nested in tabs and clusters and so on. You can try opening references based on the names you get from Get Controls Values or going recursively through the VI. You can also try investigating to see if the type descriptor tells you that you're dealing with a listbox (I don't think it does). Try having a look into the OpenG VIs to see if they deal with this.

___________________
Try to take over the world!
0 Kudos
Message 4 of 10
(3,685 Views)


tst a écrit:
Your suggestion sounds like the only plausible way to do this, but to get the values, you will have to get the reference first, which you can't do with Get Controls Values. To get the reference to all the controls, it is not enough to use the VI's Controls[ ] property, because that doesn't give you controls nested in tabs and clusters and so on. You can try opening references based on the names you get from Get Controls Values or going recursively through the VI. You can also try investigating to see if the type descriptor tells you that you're dealing with a listbox (I don't think it does). Try having a look into the OpenG VIs to see if they deal with this.


As far as the type descriptor (TD) goes, the ring is a numeric control. Only the enum has its strings included in the TD.


LabVIEW, C'est LabVIEW

0 Kudos
Message 5 of 10
(3,679 Views)


@tst wrote:
Your suggestion sounds like the only plausible way to do this, but to get the values, you will have to get the reference first, which you can't do with Get Controls Values. To get the reference to all the controls, it is not enough to use the VI's Controls[ ] property, because that doesn't give you controls nested in tabs and clusters and so on. You can try opening references based on the names you get from Get Controls Values or going recursively through the VI. You can also try investigating to see if the type descriptor tells you that you're dealing with a listbox (I don't think it does). Try having a look into the OpenG VIs to see if they deal with this.


Thanks for your help (you can probably tell I'm pushing the limits of my LabVIEW skills).

I can get all the controls with Get Controls Values, and I'm reasonably certain that I can examine the type descriptor to find out if a control is a tab/listbox/ring/etc.  Then I can make a VI that will give me a reference to the tab (similar to the one I found in this thread).  How do I get references and names for controls embedded in the tab?  There's no Controls[ ] property for a tab control that I've found.

I looked through the OpenG stuff, but I haven't found anything that I could useful for this problem.
0 Kudos
Message 6 of 10
(3,667 Views)

Tab controls get weird. Tab controls have a property called Pages which is an array of references to the pages in the tab control. One reference for each page. Index out a page reference and wire it to a property node. A page reference has a property called Controls on Page[ ] .

Mike...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 7 of 10
(3,658 Views)
Wow; it's conceptually simple but what a string of references I need to go through just to get controls from a tab.  Thanks for the help.
0 Kudos
Message 8 of 10
(3,652 Views)

JP, do you know if there are any plans for an OpenG VI which will get the references for *all* the controls on the FP? It sounds like a perfect VI for the application control palette. Then, there could be some VIs based on it, like "Find all ****" (listboxes\tabs\2D arrays\whatever).

For some reason I seem to have a recollection of seeing a debate about doing this recursively (with VIs attached?), but I can't seem to remember where (LAVA?).


___________________
Try to take over the world!
0 Kudos
Message 9 of 10
(3,644 Views)
Hi Ryan,

I know that this isn't what you were looking for, but I have a feeling that you can use it anyway. What I'm talking about is a small VI I once created, that inserted inside another VI would be able to save and retrieve all control and indicator values when needed. The beauti is that you dont have to add any other code than the VI itself and the constant/control that specifies whether you want to Load or Save the values.

Here you go...

Have fun!
- Philip Courtois, Thinkbot Solutions

Thinkbot Solutions
0 Kudos
Message 10 of 10
(3,621 Views)