LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How make array of string from different string

Solved!
Go to solution

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 ?

Безымянный.jpg

0 Kudos
Message 1 of 18
(4,124 Views)
Solution
Accepted by RavensFan

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

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

Hi Muz,

 

Why did such occur ?

When you insert a string into an empty string array you get an array with just one element.

Seems reasonable to me…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 18
(4,117 Views)

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.Безымянный.jpg

0 Kudos
Message 4 of 18
(4,087 Views)

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.

Message 5 of 18
(4,078 Views)

And you should (most probably) also initialize your shift register…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 18
(4,073 Views)

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

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

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. 

0 Kudos
Message 8 of 18
(4,054 Views)

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


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 9 of 18
(4,037 Views)
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 ?

0 Kudos
Message 10 of 18
(4,017 Views)