06-14-2015 02:23 AM - edited 06-14-2015 02:27 AM
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.
If sombody suggest on this, that would be great.
Thank you.
Solved! Go to Solution.
06-14-2015 04:46 AM
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.
06-14-2015 07:22 AM
06-14-2015 09:35 AM
thank you tst and Peter..
06-04-2018 06:58 AM - edited 06-04-2018 07:03 AM
Thnx
06-04-2018 09:55 AM
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.
06-04-2018 11:43 AM
I use a combination of the suggestions above along with what you suggest.
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
06-04-2018 12:23 PM
@mcduff wrote:
I use a combination of the suggestions above along with what you suggest.
- Get an array of references as tst stated.
- Iterate over the array pulling out references that you want by using the control label. (Note need to have unique labels)
- 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 😄
06-04-2018 02:24 PM
@mcduff wrote:
I use a combination of the suggestions above along with what you suggest.
- Get an array of references as tst stated.
- Iterate over the array pulling out references that you want by using the control label. (Note need to have unique labels)
- 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