LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

save control values by reference: I have made something that does it

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:

 

control refs.png

 

The sub vi is just a functional global to which you can either add a single control reference value or append a complete array:

 

functional global.png

 

 

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

 

 

 

 

 

Message 1 of 6
(3,857 Views)

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

Property Saver

 

Hope this helps


We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

Message 2 of 6
(3,836 Views)

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.

Message 3 of 6
(3,820 Views)

@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?

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Message 4 of 6
(3,811 Views)

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.

Message 5 of 6
(3,796 Views)

Labview classes? That doesnt sound familiar to me I will look into that thanks for the tip

0 Kudos
Message 6 of 6
(3,776 Views)