02-22-2017 02:06 AM - edited 02-22-2017 02:07 AM
@MaxiMuz1979 wrote:
[...]
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 memoryHow can the array string keeps growing if every time at the begin it has null length ?
[...]
The array in the shift register has a length of 0 only before the first call. Once the VI finished running the first time, the array in the shift register has a length of four elements. This array is NOT RESET to a length of zero elements because you DO NOT RE-INIT the shift register with an empty array.
Furthermore, you use "Insert into array" and use the iterator to insert elements. That means for the second run of the VI:
- The shift register contains a string array with four elements
- You start to PREPEND new elements
That means, runtime performance sucks and you have a "memory leak- like" behavior of growing memory consumption. However, it is not a leak, it is what you tell LV to do!
@MaxiMuz1979 wrote:
[...]
c) Add function is Rube-Goldberg. Please get rid of it
Do you mean the method of creating array ?
No, i mean the "Add" function (the yellowish triangle with '+' inside). It serves no purpose as you add 0 to the iterator. So it is a complete waste of block diagram space. Depending on the LV version, it is possible that the compiler removes that unnecessary code, but it could also bloat the execution code of the VI. Please remove it (with the constant '0').
02-22-2017 02:08 AM
@crossrulz wrote:
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.
I need to use array of strings in the loop.
02-22-2017 04:53 AM
@Norbert_B wrote:
@MaxiMuz1979 wrote:
Furthermore, you use "Insert into array" and use the iterator to insert elements. That means for the second run of the VI:
- The shift register contains a string array with four elements
really is the shift register contain all array ? I think, the shift register can contains only one member such as one string. Isn't it ?
02-22-2017 05:52 AM - edited 02-22-2017 05:54 AM
You have a single 1D array of strings in the shift register. So yes, the following is true as you state:
- There array has only elements of one specific data type (fundamental property of arrays in all programming languages)
- The array has only one dimension
However, that does not define/restrict how many elements are in the array. In your code, the array is not reinitialized to be empty for consecutive VI executions. That means that each call to VI adds new elements!
02-22-2017 05:56 AM
Hi Muz,
I think, the shift register can contains only one member such as one string. Isn't it ?
It isn't! A shift register can take any datatype you like…
I think you should take the free beginner courses offered by NI!
And I suggest you create some simple VIs to "play around" and "try on your own": such things really help to understand how certain parts of LabVIEW work…
02-22-2017 07:21 AM
@GerdW wrote:
I think you should take the free beginner courses offered by NI!
And I suggest you create some simple VIs to "play around" and "try on your own": such things really help to understand how certain parts of LabVIEW work…
What course do you mean ?
02-22-2017 07:41 AM - edited 02-22-2017 07:42 AM
02-27-2017 03:13 AM
Yes, I saw