LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reference to control different from reference panel->controls[]

Hi, I get references to all my objects on front panel from the properties panle->controls[]. In my program I use an Event case and the reference to the contol passed from the Event Case is different fom the reference obtained by panel->controls[]. I need this to be the same since I want to use this reference to search for match in ref array from panel->controls[] get the array index of thet control
Message 1 of 30
(5,579 Views)
The reference elements in the Controls[] array are of a different (less specific) class than the reference from the event structure. If you want to find the corresponding array index, get the control names (label) from the Controls[] array and then get the name from the event structure reference.

Dan Press
Ceritified LabVIEW Architect
PrimeTest Corp.
0 Kudos
Message 2 of 30
(5,563 Views)
Thanks for answer. I had hope there was an easier way to do this. If it is the different class that is the problem then using the "to more generic class" on the reference from the event case, should solve the problem, but it doesn't. The reference is the same. Any other ideas?
0 Kudos
Message 3 of 30
(5,550 Views)
Do you have tabs\arrays\clusters?
The references from controls in those (and possibly other structures) are not returned when you use the Controls[] property.
You have to go over all the references and if any of them is one of these structures you need to cast it to its specific class and extract its Controls[] property to get to the controls in it. This needs to be done recursively until there are no more structures.
I seem to remember seeing a VI somewhere that did this (maybe OpenG?), but I can't seem to find it. Maybe someone else knows.

___________________
Try to take over the world!
0 Kudos
Message 4 of 30
(5,544 Views)
Hi. The controls of interest are just numeric and string controls/indicators.
0 Kudos
Message 5 of 30
(5,539 Views)
I see, I misunderstood your question. I thought you weren't able to find the controls.
I see what you're saying. It seems the Controls[] property is to blame, because the event structure gives the same reference as a static reference would.
I tried looking around a bit, but I couldn't find anything. Maybe someone else knows why this is so.
I remember having a similar problem a while back, and if I remember correctly, I just went around it by using the static reference from the 3 or so controls that I needed.

___________________
Try to take over the world!
0 Kudos
Message 6 of 30
(5,532 Views)
Here's a workaround:
The problem only seems to apply to FP.Controls[], so you can create a tab, place all the controls in it and then get the Controls[] property for the page with all the controls, which gives refnums identical to the control's reference.
It requires another couple of nodes on the BD, and if you add more controls, you need to remember to put them in tab, but at least it works.
We're still left to wonder why the FP.Controls[] property gives other references.

___________________
Try to take over the world!
Message 7 of 30
(5,528 Views)
nfol,

Could you post a VI that indicates what you are doing that gives you different references?

I do not think I am following the issue you are seing, unless it has to do with controls vs indicators.

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 8 of 30
(5,517 Views)
Ben, I did this in 7.0:
1. Create an empty VI with a couple of controls.
2. Create references for the controls.
3. Create 2 property nodes to get the Panel>Controls[] property.
4. Wire all of them into a structure and probe them or type cast and create an indicator.
5. Run the VI. You will see that the references are different.
6. If you do what I suggested (Tab>Pages>Controls[]) the refs are the same.
This looks more and more like a bug to me (but a very weird one).

___________________
Try to take over the world!
Message 9 of 30
(5,516 Views)
Hi, thanks for help. I'm using the tab suggestion to solve my problem.
0 Kudos
Message 10 of 30
(5,511 Views)