06-11-2009 08:18 AM
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
Solved! Go to Solution.
06-11-2009 08:26 AM
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
06-11-2009 09:14 AM
Thanks!
I see what you mean.
This will do I think!
06-11-2009 10:00 AM
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.
06-11-2009 10:03 AM - edited 06-11-2009 10:05 AM
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.
06-11-2009 10:10 AM
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
06-12-2009 01:26 AM
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
06-12-2009 09:38 AM
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