LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How make array of string from different string

Solved!
Go to solution

@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 memory

How 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').

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 11 of 18
(1,301 Views)

@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.

0 Kudos
Message 12 of 18
(1,299 Views)

@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 ?

0 Kudos
Message 13 of 18
(1,287 Views)

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!

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 14 of 18
(1,282 Views)

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…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 15 of 18
(1,280 Views)

@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 ?

0 Kudos
Message 16 of 18
(1,274 Views)

Hi Muz,

 

did you notice the header on top of the LabVIEW forum?

check.png

It says "Getting started…"

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 17 of 18
(1,270 Views)

Yes, I saw

0 Kudos
Message 18 of 18
(1,245 Views)