LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Get control and indicator references in individual array

Solved!
Go to solution

Hi All,

 

Aim : How to get control and indicators references in two different arrays ?

 

What I tried :using Pane Reference i got controls but it does include indicator references.

 

 

controls.png

If sombody suggest on this, that would be great.

 

Thank you.

 

-
Amit
CLAD
0 Kudos
Message 1 of 9
(5,226 Views)

You need to iterate over the references in a for loop and for each reference check the Indicator property. You can use that data to build two new arrays.


___________________
Try to take over the world!
Message 2 of 9
(5,205 Views)
Solution
Accepted by topic author amitwadje

What tst said (see attached VI)

 



Remember Cunningham's Law
Message 3 of 9
(5,189 Views)

thank you tst and Peter..

-
Amit
CLAD
0 Kudos
Message 4 of 9
(5,169 Views)

Thnx

0 Kudos
Message 5 of 9
(4,479 Views)

IMHO accessing a control's reference in the control array like that is very fragile - any change in the order of the controls will cause issues that may not show up as errors, but as unexpected data values.

 

Best to create explicit references for each control, right-click on the ref to make a constant, then place these constants in a typedef'd cluster.  Bundle those refs into the cluster and you have a portable cluster of references you can unbundle by name.  I usually place them in a global for easy access, but you can put them in an Action Engine if you want.  Now every time you add a new control or indicator, create a new reference, create a new constant, add the constant to the typdef, bundle the reference to the typedef and you have instant access to that object's properties from anywhere in the project.  Oh yeah, this works or just about any kind of reference.

Capture.PNG

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 6 of 9
(4,472 Views)

I use a combination of the suggestions above along with what you suggest.

 

  1. Get an array of references as tst stated.
  2. Iterate over the array pulling out references that you want by using the control label. (Note need to have unique labels)
  3. Covert the reference array to a type-def cluster using array to cluster.

IMHO the advantage of the above is not having to right-click every control you need and create reference and have a huge cluster on your Main block diagram.

 

mcduff

0 Kudos
Message 7 of 9
(4,464 Views)

@mcduff wrote:

I use a combination of the suggestions above along with what you suggest.

 

  1. Get an array of references as tst stated.
  2. Iterate over the array pulling out references that you want by using the control label. (Note need to have unique labels)
  3. Covert the reference array to a type-def cluster using array to cluster.

IMHO the advantage of the above is not having to right-click every control you need and create reference and have a huge cluster on your Main block diagram.

 

mcduff


If you look at my picture, my cluster is small and I'm proud of it.  LOL  😄

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 8 of 9
(4,460 Views)

@mcduff wrote:

I use a combination of the suggestions above along with what you suggest.

 

  1. Get an array of references as tst stated.
  2. Iterate over the array pulling out references that you want by using the control label. (Note need to have unique labels)
  3. Covert the reference array to a type-def cluster using array to cluster.

IMHO the advantage of the above is not having to right-click every control you need and create reference and have a huge cluster on your Main block diagram.

 

mcduff


I like Billko's approach because ti maintains the "type-ness" of the references. With the array version they are coerced to a more generic form so the sub-VIs that use them have to know how to cast them to the proper type and have to be modified if the type changes. They may not indicate a problem until you use them so we have to run the code that uses them to verify they still work. If those references are only used in special conditions, we have make sure the special conditions happen when testing.

 

On the other hand, using the cluster, if the type of the GUI elements changes it will often break the VI since type in the reference is not compatible with the control in the cluster OR there will be a coercion dot where the cluster is filled in.

 

So...

 

While the cluster approach may seem clumsy it is more fool-proof (believe me this fool needs all the help he can get). Now if you really have a lot of references (trivia, in LV 6 there was a limit of 660 controls allowed on the FP. That total was expanded in more recent versions. You would like to see the VI were I discover that trivia!), the cluster can be filled in part by part in a sequence of states that run at start up before passing the cluster off to the AE to share with the rest of the application.

 

Just my 2 cents,

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 9 of 9
(4,447 Views)