LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Controls[] question

Hallo,

say I have a VI with some controls and indicators.

If I get the VI's panel refnum and then the Controls[] property I get the
array of references. But which array element belongs to which
control/indicator of the referenced VI. Is there a way to retrieve an array
or cluster with names information, or do I have to scan the references for
the name of the referenced control/indicator? That would be some
cumbersome.

Thanks

Oliver Friedrich
0 Kudos
Message 1 of 7
(3,350 Views)
IMHO, scanning controls[] references for a control with a specific name is absolutely natural solution and I don't see any good alternatives. If you require to perform this operation frequently you can always construct your own subvi, and this will be for sure really handy.
0 Kudos
Message 2 of 7
(3,350 Views)
Here's a subvi you can use that I created a while back for just this issue. Input the path of the vi in question. The outputs are 2 arrays: The labels of the controls/indicators and a boolean array. Each boolean array element indicates whether the corresponding label array element is an indicator (TRUE) or a control (FALSE).
==============================================

0 Kudos
Message 3 of 7
(3,350 Views)
And just to answer your question, the Controls[] property generates the references in the 'Z' order of the controls on the panel.

So if you really wanted to, you could use the "Move to Front", "Move to Back" feature and set the order the the references will be generated. Though I'm sure you'll find it much easier just to search for the needed control by it's label since the Z order can change if you're not carful.

Ed


Ed Dickens - Certified LabVIEW Architect
Lockheed Martin Space
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
0 Kudos
Message 4 of 7
(3,350 Views)
Also, I'm sure that each call for Controls[] property always retern to you an array of referencies in exactly the same order. So a scan for name/index you can perform once at the very beginning and re-use index values later.
0 Kudos
Message 5 of 7
(3,350 Views)
Hi,

It isn't the 'Z' order, but the tabbing order that describes the return
values. To set the tabbing order,use "Set Tabbing Order" from "edit " menu.

This order will always be the same, untill you change it.

Regards,

Wiebe.

"Ed Dickens" wrote in message
news:5065000000050000005C700100-1079395200000@exchange.ni.com...
> And just to answer your question, the Controls[] property generates
> the references in the 'Z' order of the controls on the panel.
>
> So if you really wanted to, you could use the "Move to Front", "Move
> to Back" feature and set the order the the references will be
> generated. Though I'm sure you'll find it much easier just to search
> for the needed control by it's label since the Z order can change if
> you're not
carful.
>
> Ed
0 Kudos
Message 6 of 7
(3,350 Views)
Wiebe is correct. I must have been typing a bit faster than I was thinking.

The Controls[] property does indeed generate it's references in the 'tab' order that is set for the panel controls.

There are two other properties that give references to front panel objects that do generate the references in the 'Z' order. These are 'Decorations[]' and 'All Objects[]'. Since both of these can give references to panel object that are not controls or indicators, there is no tabbing order to go by, so they both use the 'Z' order.

Ed


Ed Dickens - Certified LabVIEW Architect
Lockheed Martin Space
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
0 Kudos
Message 7 of 7
(3,350 Views)