LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Better way of "Cluster to array"

Solved!
Go to solution

Hello and good day!

A cluster is created with a specific order of elements. Converting it to an array with "Cluster to array" is supposed to index the elements in the same order as in the cluster.

Means, the content of cluster element 0 will go into array index 0 etc, but it doesn't do it that way. If that's intended, I don't know. For me, it's illogical.

 

Now I'm seeking to create a better cluster to array. Why? Because you cannot auto-index clusters in a FOR loop. You can index the cluster element array from Cluster Info VI, but this array wouldn't let you read the single cluster elements, else it would be easy to create an equally sorted array.

 

Anyone has ever done that swiftly?

0 Kudos
Message 1 of 6
(1,055 Views)

@MaSta wrote:

Hello and good day!

A cluster is created with a specific order of elements. Converting it to an array with "Cluster to array" is supposed to index the elements in the same order as in the cluster.

Means, the content of cluster element 0 will go into array index 0 etc, but it doesn't do it that way. If that's intended, I don't know. For me, it's illogical.

 

Now I'm seeking to create a better cluster to array. Why? Because you cannot auto-index clusters in a FOR loop. You can index the cluster element array from Cluster Info VI, but this array wouldn't let you read the single cluster elements, else it would be easy to create an equally sorted array.

 

Anyone has ever done that swiftly?


They index correctly for me.

billko_0-1678124378441.png

Perhaps I'm not understanding something?  It states in the help that they come out in the same order, so I'm not sure what we are talking about.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 2 of 6
(1,050 Views)

@MaSta wrote:

Means, the content of cluster element 0 will go into array index 0 etc, but it doesn't do it that way.


Can you produce code showing that it doesn't do it this way?  I've never had a problem with it not doing that.

 

Is there a chance maybe the cluster you're using has been arranged on the front panel to be visually in one order but if you look at the real order of the elements, it's not in the same order?

Kyle97330_0-1678124826457.png

 

Message 3 of 6
(1,046 Views)

Instead of convoluted descriptions, just attach a small example that shows the problem and we can tell what you are doing wrong. (Yes, most likely your cluster order is not what you think it is. If you create a cluster, the elements are ordered in the order you add them. As a quick check, right-click on the cluster and "auto sizing...arrange vertically". Now they will be in cluster order, first element on top. Did the order change?)

Message 4 of 6
(1,038 Views)
Solution
Accepted by topic author MaSta

Ok, ok, I found out what happened. I actually re-ordered the cluster in one VI where it's a control, because I also wanted to have it in a certain tabbing order, then copied it over to a sub VI where it's supposed to be ann input control and now checked and the order of elements is totally garbled. Don't know how and why, because before I re-ordered it in the source it was not that garbled. However, re-ordering it in the sub VI now solved the problem. 

 

Sorry for bothering you.

0 Kudos
Message 5 of 6
(972 Views)

Hi MaSta,

 


@MaSta wrote:

Ok, ok, I found out what happened. I actually re-ordered the cluster in one VI where it's a control, because I also wanted to have it in a certain tabbing order, then copied it over to a sub VI where it's supposed to be …


There's a reason why you should create typedefinitions of all your clusters…

Really!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 6
(960 Views)