LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Control refs. give coersion when built into array

Solved!
Go to solution

I have a front panel with (IMO) too many controls. To help deal with all of them I build an arrary of references that I can index or pass to subs. However I noticed that every control ref produces a coersion dot when I build them into an array. Two questions:

 

1) Is there a way to avoid this? and

2) If not, will it cause problems later if I am trying to find a specific one by comparing it to other control refs?

 

Coersion dots on build array 

 

 

Message Edited by StevenD on 12-16-2008 02:43 PM
0 Kudos
Message 1 of 5
(3,052 Views)
Solution
Accepted by topic author StevenD

1) no

 

2) yes (maybe)

 

All elements in an array can only differ in thier value. The coercion dot is telling you that those refs are being cast to a generic type. If you count on the ref being a specific type then you will run into issue.

 

Rather than building an array I'd suggest creating a cluster (type def'd) with the proper ref types. This makes my development easier since I don't have to count to find a ref, I can just pick it from a list (unbundle by name).

 

Just trying to help,

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 2 of 5
(3,043 Views)
I do not think there is a way to avoid these coercion dots, and they should not cause you any trouble.  The coercion is forcing a reference of a specific type of control (numeric, boolean, etc) to a more generic control reference that includes all the elements in your array.  However, for your purposes a reference is just a number, and I doubt that LabVIEW assigns the same number to more than one control regardless of type, so you can do your comparison.  It's like taking a bunch of unique numbers, with different representations, and combining them into an array.  You'll get coercion dots so that all numbers share the same representation, but you can still search for a single number within the array without problems.
Message 3 of 5
(3,042 Views)
Thanks for the swift replies. My code seems to work so far and I don't think that I will need to do anything that only a more specific control could handle. I will probably keep them as they are since I have the array documented and need to auto-index it in a few places.
0 Kudos
Message 4 of 5
(3,030 Views)

StevenD wrote:

will it cause problems later if I am trying to find a specific one by comparing it to other control refs?


That depends on your LabVIEW version and on where you get the reference from. There was an issue in 7.x and earlier where comparing different references to the same control would fail if the reference was strict vs. non-strict. This was fixed in LV 8.0.


___________________
Try to take over the world!
0 Kudos
Message 5 of 5
(2,995 Views)