LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Choose case in a case structure by cluster element name

I have a cluster bundled by name, and I'm trying to set up a case structure that operates a different case for every element of the cluster. I can unbundle the cluster, and I know what to do inside the case structure, but I'm not sure how to get the case structure to recognize the different names of cluster elements and select a case accordingly. Does anyone know how to do this?

 

Thanks very much

0 Kudos
Message 1 of 10
(3,408 Views)

Can you post your VI?  What does your cluster look like?

 

A case structure implies options based on the value in a given input.  It sounds to me like you are trying to work with mulitple values from different parts of a cluster.  A case structure is not appropriate for that.

 

I think you are coming up with a scheme that is far more complicated than it needs to be.  If we see what your VI looks like, we can probably suggest a better method that can actually work.

0 Kudos
Message 2 of 10
(3,402 Views)

You can use the property node of the cluster control to get the names: create>property node> controls. The controls property is an array containing a ref to each control in the cluster. From there you can strip out the label names to feed your case selector. Hope that helps.

PaulG.

LabVIEW versions 5.0 - 2020

“All programmers are optimists”
― Frederick P. Brooks Jr.
0 Kudos
Message 3 of 10
(3,399 Views)

That doesn't make any sense to me.

Witch cluster element should be selected?

A case structure can only operate in one case, it can't go though all your cluster elements one by one. It can only do one case. How would it have to select witch case to run?

 

And I don't think it is possible to get the name of a cluster element from a wire, maybe from a cluster control.

 

0 Kudos
Message 4 of 10
(3,391 Views)

Paul,

 

That may work if you actually have a control.  But what if the only thing you have is a wire that is the datatype of the cluster that might be coming out of a subVI?

 

EDIT:  I was late in my reply.  Thanks DKFire for asking the question I was thinking of regarding the control vs. wire.

0 Kudos
Message 5 of 10
(3,379 Views)

Something like this?

PaulG.

LabVIEW versions 5.0 - 2020

“All programmers are optimists”
― Frederick P. Brooks Jr.
0 Kudos
Message 6 of 10
(3,377 Views)

Good.  But there you have an actual control.  Many times that I use a cluster, the cluster (while I would have typedef'd it) would exist in a diagram strictly as a wire.  Such as coming from the output of a subVI that may have acquired data and bundled it together on the wire.

0 Kudos
Message 7 of 10
(3,372 Views)

Paul's VI works for my program, thank you so much for your help everyone!

0 Kudos
Message 8 of 10
(3,354 Views)

@Ravens Fan wrote:

Paul,

 

That may work if you actually have a control.  But what if the only thing you have is a wire that is the datatype of the cluster that might be coming out of a subVI?

 


The OpenG Varient Cluster tools are very useful for these kinds of things (works on the wire):

GetClusterElementNames.pngVCluster.png

-- James

Message 9 of 10
(3,346 Views)

Nothing against the OpenG tools, but similar functions are included with LabVIEW in the VariantDataType library, vi.lib\utility\VariantDataType.

Message 10 of 10
(3,318 Views)