07-03-2017 08:28 AM
Hi,
I want to first thank you all in this forum for your help every time thank you very much.
As you saw in the title, I want to search in array of cluser as you see in picture, i means to search by the first element in the array in cluster and to find the indice of array of cluster ???
thank you.
Solved! Go to Solution.
07-03-2017 09:07 AM - edited 07-03-2017 09:07 AM
Hi Sarah,
it's not clear from your description which problems you encounter!
What do you want to search? What do you want to find?
What is your problem to index elements from your array?
In the images you (seem to) show a 1D array of cluster of 1D array of strings. You need to use IndexArray on the outer array, then Unbundle(ByName) on the cluster, then IndexArray on the inner array…
07-03-2017 09:18 AM
i want to search by name of first element for example in picture (force or pression...) and to find the index of array of cluster .
07-03-2017 09:26 AM
I'm not certain I understand your Data Structure, nor what it is you want to do.
I assume you are trying to use Search 1D Array. This has the requirement that the Search Element exactly matches one (or more) elements of the Array being searched. If your Array is an Array of Clusters, then it is looking for an exact match for one of the Clusters.
My first question is why do you have a Cluster in the first place? It seems to consist of a single element, "tab", that is an Array of Strings (again, I'm guessing, but I see both "temper", a string, and "4", what appears to be a numeric, in the Array, and all Array elements have to be the same type, hence Array of String). [Ah, a partial answer -- the Tab clusters might consist of Arrays of different lengths, and a 2D Array needs to be rectangular. Of course, if you have fewer "temper" data, you can leave cells blank, a legitimate String value].
Of course, even if you get rid of the Cluster and create a 2D array of Strings, you still want to do a 1D search. One way to do this is to create an "Index" array that consists of the first (non-numeric) element of each row/column (depending on how you arrange the 2D array), i.e. "temper", "pression", etc. You search this 1D array, it says "temper is at position 0", so you know you need to look at row (or column) 0 of your 2D array.
Bob Schor
07-03-2017 09:33 AM
Something like this:
/Y
07-03-2017 09:34 AM - edited 07-03-2017 09:35 AM
I see that the arrays are of different size. So I understand doing the Array of Cluster of Array. But what I would do is move the name out of the inner array. It should be its own element in the cluster. Then your array can be numeric (since it looks like you are just holding numeric data, it would make more sense this way).
So for searching, use a FOR loop and stop the loop when the desired name is found. You should also have an indicator stating if the name was found.

07-03-2017 09:35 AM
Hi Bob_Schor,
I have already tested array 2D for do that, but my arrays have different sizes,So when I add a array in the 2D array, the size of array It does not change,Then the only solution was to create this method on picture.
07-03-2017 09:39 AM
Hi crossrulz,
You mean that I have to divide this Array of Cluster of Array into a numerical array and his name in the Array of Cluster of Array?
07-03-2017 09:46 AM
@Sarah_LAB wrote:
You mean that I have to divide this Array of Cluster of Array into a numerical array and his name in the Array of Cluster of Array?
Have to? No. Would it make your life (and whoever later has to figure out your code) easier? Yes.
So my recommendation is an Array of Cluster of {String, Array of Numeric} If you open the snippet in LabVIEW, you will see better what I mean.
07-03-2017 09:51 AM
Hi ,
I found the solution ,
like this.
Thank you for you all guys.