06-08-2022 12:41 PM
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.
06-08-2022 12:52 PM - edited 06-08-2022 12:54 PM
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.
06-08-2022 12:54 PM
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.
06-08-2022 09:06 PM
@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
06-08-2022 09:53 PM
You can convert them into variants.