03-06-2023 11:28 AM
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?
Solved! Go to Solution.
03-06-2023 11:40 AM - edited 03-06-2023 11:43 AM
@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.
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.
03-06-2023 11:47 AM
@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?
03-06-2023 11:56 AM - edited 03-06-2023 12:27 PM
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?)
03-07-2023 02:21 AM
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.
03-07-2023 03:14 AM
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!