LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I build a string array of unknown length?

I am trying to build an array of unknown length with a string as element? I was unsuccessful with the Build Array function...
0 Kudos
Message 1 of 7
(3,978 Views)
This is one of the nice things with LabVIEW. You don't need to declare length. The build array is what you want. Here is a quick example.
0 Kudos
Message 2 of 7
(3,978 Views)
Use Build Array to append to an existing array. After placing Build Array on your diagram, add an input to it (just stretch it with the mouse or right click and select Add Input). Wire the top input to your existing array and the bottom input to the string you want to add to the array. In labView 6.1, the top input in Build Array will automatically change to an array input. In LabView 5.1 or older, you have to right click on the input and select Change to array (or some words to that effect).

See the attached LabView 6.1 example.
Message 3 of 7
(3,978 Views)
Thanks for your response gbush. The only thing is that the number of string elements being generated cannot be predetermined. To give you a little more detail, I am trying to find all the strings within a given range(limited by two strings) and insert it into an array. The strings are automatically generated so I cannot use a stop button. Any ideas to where to go from here is much appreciated.
0 Kudos
Message 4 of 7
(3,978 Views)
Thank you Al. Please see my previous comment to gbush. I have tried your solution already. However, I have to create an array when the string elements become available and cannot use any stop button. After all elements are inserted into the array, I have to pass it as a local variable somewhere else as part of a bigger VI.
0 Kudos
Message 5 of 7
(3,978 Views)
The stop button was included only for the example. Whnever you want to add an element, use Build Array as in the example with the array wired to the top input and new string wired to the bottom input.
0 Kudos
Message 6 of 7
(3,978 Views)
How are the strings automatically generated? The examples that the others gave you should give you an idea on how to dynamically build the array. Instead of the button, replace it with whatever you use to test if a new string is present. The key to the examples is the shift register that initially has an empty array and the build array function.
0 Kudos
Message 7 of 7
(3,978 Views)