LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Different Size Cluster Depending on Case

I want to have a case structure whose output would be a cluster of one size if True and a cluster of a different size if False. Basically I have a cluster and if a certain condition is met  I want to add to it. Is this even possible given that clusters have a fixed size? And if it is possible how would I do that.

0 Kudos
Message 1 of 5
(678 Views)

You cannot have different clusters on the same wire. Clusters are fixed at compile time.

If all elements are the same type, maybe you could use an array?

 

It typically helps to explain what you are trying to do, not how you are trying to do it. I am sure there is an easy solution.

 

For example you could create the largest possible cluster and hide certain elements based on state.

0 Kudos
Message 2 of 5
(664 Views)

The simple answer is NO!  The tunnel and wire out of the case must be of the same type.  

 

Now what you could do is pass out a reference to the chosen cluster or a class instance and use dynamic dispatch to override your "Add something to me" method.

 

Essentially you need to decouple the Do Something from the caller and hide the detailed implementation in the Do code.


"Should be" isn't "Is" -Jay
0 Kudos
Message 3 of 5
(660 Views)

@JÞB wrote:

The simple answer is NO!  The tunnel and wire out of the case must be of the same type.  

And the slightly more complicated answer is "It depends".  Take the infamous NI Queued Message Handler, which passes "Messages" around, where a Message is a Cluster with two parts, which I'll call the "Message" (which is typically either a String, a data type which has "variable size", or an Enum (which, once defined, has a fixed size) and a second part, which I'll call the "Message Data", which is typically a Variant, a LabVIEW Type that can accept any (specific) type of Data -- numeric, Boolean, 1D Array (of any size), 2D Array, String, etc.  The only "restriction" is that you need to know the type of data associated with a specific Message in order to extract its Data.  [There are also a series of functions that can tell you the Type of the data in the Variant, so you can sort-of even get around this "restriction" with a bit of cleverness and hard work ...].

 

Still, this "exception" also follows the "rule" that the Cluster definition is "fixed", so @JÞB 's Reply is a Quantum State between "True", "False", and "Maybe" ...

 

Bob Schor

0 Kudos
Message 4 of 5
(597 Views)

You can convert them into variants.

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 5 of 5
(593 Views)