01-11-2011 05:39 AM
I'm not sure if this is the place to post this, but I think this maybe useful, as I sometimes see questions on how to save and restore control values.
I'm still a novice programmer, but I have read Ben's nugget a while ago on how to use control references, and use 'to more specific' class to test whether a control is of a certain type.
I have used this to save control data of apps I write. I usually divide my programs in tabs, and in every tab a subcontainer with a VI running (and its own front panel).
So I use only this to queue up control references from all VI's that have a front panel that I want to save values from:
The sub vi is just a functional global to which you can either add a single control reference value or append a complete array:
I have attached the library which saves all control values to a text file. It uses the controls LABELS to identify which control it is, so avoid duplicates (it''ll still work).
Currently it works for:
-Booleans (latching are ignored)
-Rings, Enums and Numerics
-paths
-strings
All other types are just ignored so it should still work. I hope this is of use to someone, and I am always happy to receive some feedback so I can improve my programming.
Felix
01-11-2011
06:32 AM
- last edited on
04-26-2025
04:53 PM
by
Content Cleaner
Thanks for sharing your tool, this idea is nice but I think many different tools already exist.
OpenG Read / Write Section Cluster functions and Read / Write Panel to INI
Hope this helps
We have two ears and one mouth so that we can listen twice as much as we speak.
Epictetus
01-11-2011 07:26 AM
Another way to test for control class is to use the utilities in <vi.lib>\Utility\VariantDataType. This uses the actual value, however, not the reference. If you have the reference, using a Value property gets you the info you need to use the utilities.
One other thing you may consider - using LabVIEW classes. Whenever I see the same sort of operation being done multiple times with huge case statements, I think classes. Try it and see what you get.
01-11-2011 09:05 AM
@DFGray wrote:
Another way to test for control class is to use [...]
Is there a way to get a GObject's class from a reference?
01-11-2011 09:34 AM
Yes, but you need a lookup table to do it. The Class ID and Class Name properties will give you this information. These properties show up on a Generic reference, which is the parent of GObj. This is good, because such things as connector panes and flat sequence frames are siblings to GObj. These will return the specific type for whatever the reference is. This can create problems if you are looking for classes of objects, in which case it is easier to try to coerce to the general class and see if it errors.
Note that you should use Class ID for any programmatic control, since Class Name is subject to change from version to version of LabVIEW. They are functionally equivalent.
I do have a lookup table, but cannot post it, since it contains a lot of hidden objects.
01-11-2011 10:37 AM
Labview classes? That doesnt sound familiar to me I will look into that thanks for the tip