LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to Programmatically Empty an Array

Solved!
Go to solution

Retired and just playing around with the LV community addition to see how much I have lost.  Now checking out some old test equipment.  

Novice question:

I built a simple test program and got it to work but have an issue with the array indicator displays on the front panel.  On start, the arrays are empty and greyed out as expected. Pressing the Run Test button starts a while loop that iterated and fill in the expected data then ends and returns to the main loop.  Upon pressing the Run Test button again, I would like to have the arrays cleared before the next data set is added.  Instead, new data is inserted into the arrays from the top (0 index) and the old data remains and is pushed downward.  I can perform a “Data Operations, Empty Array” procedure from the Front Panel but can’t find a way to do it programmatically before the restart to the while loop.  I have tried using property nodes with no success. Reinitialize to Default Value clears the display momentarily but then the old data returns.

PS, I know it’s not good form to use a local variable but could not recall any other way to reset the Run Test button.

Message 1 of 8
(936 Views)
Solution
Accepted by topic author ee1993

Your main problem is the data being stored in the Feedback Nodes.  Replace those with Shift Registers and you can then initialize the values to empty when the inner loop starts.

 

Along similar lines, you might as well just use Build Array instead of the Insert Into Array.  They do the same thing, but the Insert Into Array makes things a little more complicated.


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
Message 2 of 8
(916 Views)

I spoke too soon accepting the solution.   Made your suggested changes but I am still getting the old data so I must be missing something. 

0 Kudos
Message 3 of 8
(882 Views)

Revised VI

0 Kudos
Message 4 of 8
(881 Views)
Solution
Accepted by topic author ee1993

OK, Got it.  Just needed to add zero constants to the input terminals of the shift registers.  That resets the values each time the RunTest is pressed.

Thanks!

Message 5 of 8
(857 Views)

@ee1993 wrote:

OK, Got it.  Just needed to add zero constants to the input terminals of the shift registers.  That resets the values each time the RunTest is pressed.

Thanks!


Yes, a "naked" shift register keeps values between runs, that's the "hack" behind Functional Globals.

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 6 of 8
(751 Views)

Here is an update to my first attempt at a simple program.  This should more closely follow good LabView practices and style.  Event driven, so no polling in the outer loop.  Any critique or suggestions are welcome.

0 Kudos
Message 7 of 8
(669 Views)

There is no need for the wait in the main loop.  The Event Structure will limit the loop rate.


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
Message 8 of 8
(660 Views)