LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Need a generic control reference

Hi All,

 

Please see attached.

 

I'm trying to simplify a VI here that has a bunch of controls and wires by making lookup dictionaries for a specific data type. Example: Create a variant lookup table from an array of string references and their names, call it "system info".

 

The problem is that I can only group references of a particular type together for a lookup table - I end up making a polymorphic "ref array to dictionary" VI and this isn't flexible.

 

Is it possible to have a more generic VI that doesnt care what type of references I'm taking in?

 

Oh, P.S. I hate clusters.

 

 

 

0 Kudos
Message 1 of 11
(3,882 Views)

You can use the "to more generic".

 

ToMoreGeneric.png

0 Kudos
Message 2 of 11
(3,868 Views)

Hey! Thanks a lot for the input.

 

After going down the path you sent me down, I believe I may have found an even easier way.

 

By right clicking on my ref in, apparently (havent ever played with this) I can select VI server class and just make it a generic control. Then I can wire anything I please right in to this subvi and my "ref array to dictionary" is no longer polymorphic!

 

WOOHOO

 

Thanks brah.

0 Kudos
Message 3 of 11
(3,849 Views)

Glad you got it working.  Mark it as accepted solution.

 

Michel

0 Kudos
Message 4 of 11
(3,844 Views)

 

In the example shown, the 'To More Generic Class' function is completely unnecessary.  The references will be coerced to a common class at the input of 'Build Array'

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 5 of 11
(3,824 Views)
Well yes and no. They will be coerced to a common type, which in this case is a control reference. However, the readability stinks as it is easy to miss those little dots. Better to do the explicit cast so there is no question what the result is.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 6 of 11
(3,783 Views)

 

I disagree.  I my opinion, the code is more readable without the 'To More Generic Class' functions.  Even if you don't notice those coercion dots, there's nothing confusing about it.

There are cases where a latent bug may be caused by undesirable coercion, but this isn't one of them.

 

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 7 of 11
(3,757 Views)

Here's a forum discussion link to coercion dot, so anyone can make their mind and you may add your though there.

 

http://forums.ni.com/t5/LabVIEW/Dealing-with-Coercion-Dots/m-p/926925/highlight/true#M416411

 

The simple example was to show that classes exist in LabVIEW, simple as that.

 

Michel

0 Kudos
Message 8 of 11
(3,751 Views)
The big point to be made here is that going to a lot of trouble just to avoid using clusters because you "hate" them (an absurd proposition on its face) is a hack. Putting them into an array is misusing the array datatype. A array holds a collection of the same thing, like a collection of voltage readings or a collection of identifier strings. What you are doing is forcing into an array a collection of fundamentally different things.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 9 of 11
(3,705 Views)

Not really. References are not "different things".

I get to decide what is the "same" (bundling is also putting different things together). The inability to programmatically cluster things is a huge disadvantage to clusters in addition to their slow lookup speed.

0 Kudos
Message 10 of 11
(3,677 Views)