LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

create reference with caption info

Solved!
Go to solution

Hi,

 

I have on my front panel a lot of controls, 152.

I have an array of 152 elements with a value.

I want to load the values in the right controls. All the controls have a caption with the same value as the element index.

Is it possible to load the values in a loop?

Get the element, get the reference and load the data via a property node??

So my question is it possible to create a reference of a control by giving as input the caption of the control??

 

Any suggestions are welcome, I'd like to avoid connecting 152 values to 152 controls.

 

Thanks Kim

0 Kudos
Message 1 of 8
(2,789 Views)
Solution
Accepted by topic author KimT

Kim,

 

The loop is the right idea.

 

You cannot create a reference from the caption.  You can get an array of the references to all the controls on the panel.  Then you can search for the caption which matches the one you want.  When you find a match, use that reference to write to  a Value property node.

 

Captions are easily changed.  It is probably better to use the label, which cannot be changed programatically while the VI is running, for the search and match.  You can show the caption to the user and hide the labels if that is better for the user interface.

 

Lynn 

0 Kudos
Message 2 of 8
(2,788 Views)

Thanks!

I see what you mean.

This will do I think!

 

 

0 Kudos
Message 3 of 8
(2,781 Views)

Hi,

I tried it out, and everything seems to work untill there are indicators on the front panel. Then errors occur when getting the caption of all the controls.

Am I using the right properties to get the captions. I'll include a piece of my vi.

Thanks for your help.

 

0 Kudos
Message 4 of 8
(2,773 Views)

Your array indicator has no caption, so you cannot get it, of course. Either ignore the error or show the caption of the indicator too.

 

You could also test with another property node if the control is a control or indicator and place the second property node inside a case structure to only handle controls.

Message Edited by altenbach on 06-11-2009 08:05 AM
0 Kudos
Message 5 of 8
(2,769 Views)

Kim,

 

Your Captions array has a label but no caption.  The error 1320 occurs if you attempt to do anything with a non-existent caption. You could cancel that error if you know that a caption exists for all controls or indicators you need to modify.  It does not matter whether it is and indicator or control.  The property nodes and references (and error 1320) apply to both.

 

Your numeric controls all have empty labels.  Any search on labels will not be able to distinguish them from each other.

 

If you are going to manipulate controls (or indicators) this way, it is best to give each control and indicator on the panel a unique label and work with that.  Use the captions to display to the user the text you want the user to see.

 

Lynn 

Message 6 of 8
(2,765 Views)

Hi,

 

Thanks for the feedback.

I'm editing an existing piece of code, where only the captions are filled in. So I have no option.

But I'll just cancel that error.

 

I appreciate your help!

 

Kim

0 Kudos
Message 7 of 8
(2,729 Views)

Kim,

 

You can add labels to existing controls or indicators.  First make the label visible.  Type in the name.  Then uncheck Label from the visible items list if you do not want the user to see the label.

 

It might be worth taking the time to do this if you expect to be working with the array of references.

 

Lynn 

0 Kudos
Message 8 of 8
(2,717 Views)