LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Detrmine all combinations of string arrays

I have an unknown number of 1D string arrays (until runtime). I need to generate a string for every combination using one element at a time from each array. For example, if at runtime there are two arrays with A,B and X,Y then I need to generate AX,AY,BX, and BY. At runtime there could easily be 10 arrays with 6 elements each, so there are a lot of combinations. The 1D arrays are not necessarily the same length.
0 Kudos
Message 1 of 6
(3,168 Views)
henry;

Check the attachment. The VI "Example Combination of strings.vi" is the one that does the combinations. The other one is testing the VI.

Let me know if it is of help.

Regards;
Enrique Vargas
www.visecurity.com
www.vartortech.com
0 Kudos
Message 2 of 6
(3,168 Views)
This would work if I knew how many 1D arrays I have. If there were three 1D arrays at runtime, I would have no way of adding a third ForLoop. Then the next time the program calls this vi there might be 9 1D arrays and the time after that there might be 4, etc.
0 Kudos
Message 3 of 6
(3,168 Views)
henry;

Well, this is the part where creativity plays an important role.

I don't know how your program get the different arrays. I am going to assume is by reading a file. Each line in the file is a different array, for example:

A B C D
X Y Z
1 2 3 4 5 6

The attached VI use the VI I posted before. It reads the file, counts how many elements are in each array, and then combines them all. It even do a simple check to see if the final result is right. Along with the VI there are two test files.

In order to run the VI, you will need a modified version of the Read From Spreadsheet File.vi that read strings. I included it in the zip file. You can download that VI from here:

www.jyestudio.com/lview.shtml

Regards;
Enriq
ue
www.vartortech.com
0 Kudos
Message 4 of 6
(3,168 Views)
Excellent. This works very well. FYI, the link to the website does not work.

Thanks
Henry
0 Kudos
Message 5 of 6
(3,168 Views)
Thanks for letting me know about the link. The website is up again.
www.vartortech.com
0 Kudos
Message 6 of 6
(3,168 Views)