02-21-2017 08:19 AM
Hi everyone !
I need get array of strings, which consist from defined (selected defined algorithms) strings. This string coming from "Pick Line" and I tried do this with help function "Insert Into Array Function " . But on the output I am getting the array with only 1 member.
Why did such occur ?
Solved! Go to Solution.
02-21-2017 08:29 AM
Your VI needs improvement (quite some) in order to be readable.
Besides that, your issue has to do with a missing shift register for the string array.....
02-21-2017 08:32 AM
02-21-2017 09:03 AM
When you insert a string into an empty string array you get an array with just one element.
Seems reasonable to me…
I solved this problem. I can't get used to LabView. I must to looping the output functional block on the input through buffer.
Look like this.
02-21-2017 09:07 AM
If you are always putting the new element at either the beginning or end of an array, then you should just use Build Array. Insert into Array should only be used when you might be "inserting" new elements in the middle of an array.
02-21-2017 09:11 AM
02-21-2017 09:13 AM
Your VI still requires a lot of rework to be in proper shape. There are couple of code segments which can create severe issues on the long term:
a) Uninitialized shift register will keep the data from the last VI execution (as long as the VI stays in memory!). That means that your string array keeps growing with repetitive VI calls until you unload the VI (most likely shut down LV) or your systems runs out of memory
b) A for loop already has a method of limiting the number of iterations. Your conditional terminal makes no sense if the VI connected to N already passes '4'
c) Add function is Rube-Goldberg. Please get rid of it
d) 'sub-optimal' wire routing leads to difficult readable code. If more code is added, this adds up to a real pain
02-21-2017 10:10 AM
One of the biggest hurdles that non-LabVIEW people face when starting is dealing with dataflow instead of variables. In other languages, you would declare an array with the desired number of elements, then populate them sequentially within the for loop. Here, "Out Array" is not a variable which is appended at each iteration of the loop, but an indicator on the front panel which is "re-assigned" at each iteration of your loop.
If you do not need "Out Array" updated at each iteration of the loop, you could use an auto-indexing output tunnel (instead of the shift register) and place "out array" outside the for loop.
02-21-2017 11:52 AM
My first thought is "where is the data used to pick line?" If that is a giant string that comes in before the loop, you could just use Spreadsheet String To Array to turn the giant string into an array of strings (an element for each line) and then use an Auto-indexing Tunnel to loop through the lines. It would greatly simplify your code (no need to wire the N or use the conditional terminal, eliminate the Pick Line and the need to build the array inside of the loop, etc.)
02-22-2017 01:26 AM
a) Uninitialized shift register will keep the data from the last VI execution (as long as the VI stays in memory!).
I agree with it.
That means that your string array keeps growing with repetitive VI calls until you unload the VI (most likely shut down LV) or your systems runs out of memory
How can the array string keeps growing if every time at the begin it has null length ?
b) A for loop already has a method of limiting the number of iterations. Your conditional terminal makes no sense if the VI connected to N already passes '4'
- I know! It will be changing
c) Add function is Rube-Goldberg. Please get rid of it
Do you mean the method of creating array ?