ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reset array for continuous appending

Solved!
Go to solution

 

Hi,

 

I'm writing a program that collects data and outputs an array at each iteration of a For loop.

The arrays are concatenated into a bigger array.

So the big array grows bigger at each iteration of the For loop.

 

Now, I found that if I call my program several times without exiting LabVIEW, the new execution appends the new array to the old one.

That happens even if I specify a new file to write to; apparently, the Array is never reset and remains in memory even after I stop execution.

 

I searched for "Reset Array" on the forum, but in this case I don't just want to re-initialize it, I want to flush any value in that array.

Can somebody help me with this?

 

I'm fairly new to LabVIEW.

Thank you so much,

 

Nicolas

 

0 Kudos
Message 1 of 5
(6,949 Views)

To start the For loop with an empty array (which I think is what you want to do), simply wire an empty array to the input shift register (from outside the For loop).

 

0 Kudos
Message 2 of 5
(6,943 Views)
Solution
Accepted by htnicolas

Simply right-click the left edge of the shift register on the left and select "create constant". Voila!

 

(this will create a constant of the correct type automatically, in this case an empty 1D array of strings)

Message 3 of 5
(6,936 Views)

An empty constant "resetting" the shift register is of course a valid way. Nevertheless, i would try to get rid of the "Build Array" function at all.

 

From looking into the code, my first statement is:

Front Panel as well as Block Diagram are both way too large. Not everyone sitting in front of a computer monitor has a graphical resolution of 4096x3072 pixels. So most people will have to scroll around a lot when working with this VI. This is definetly subject to change.

Next thing: As Altenbach noted, your shift register for the string array is not initiated hence leading to the behavior you are currently observing (working as expected!).

I suggest you to completly remove the shift register and use auto-indexing outputtunnel for the string. This will change the VIs behavior since you do receive a 2D-string array instead of the 1D array you are currently working with. Nevertheless, 2D array has no need for the "New Line" constant if used properly.

 

Conclussion:

Remove shift register by working with auto indexing tunnels. This will also make "New Line" constants obsolete.

 

hope this helps,

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 4 of 5
(6,926 Views)

Thank you Altenbach for your solution. I think you've helped me before on another topic!

 

@Norbert B,

Thank you very much for the advice.

I work on a double screen, that's why it's so big. I'll try to reduce the size by saving some SubVI's. I really need to get some good habits to make my program clearer.

As for the Array, I'm gonna try your solution. I had some apprehension with 2D Arrays, especially regarding file output (I was thinking about 3,4,n-Dimensional Arrays, and how those would be written to a file? The thought of it scared me). That's why I did all this ugly work, just to get a 1D array.

 

Thank you again everyone.

 

0 Kudos
Message 5 of 5
(6,905 Views)