취소
다음에 대한 결과 표시 
다음에 대한 검색 
다음을 의미합니까? 

How to Programmatically Empty an Array

해결 완료!
솔루션으로 이동

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.

1/8 메시지
3,458 조회수
솔루션
주제 작성자 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.



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
2/8 메시지
3,438 조회수

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 포인트
3/8 메시지
3,404 조회수

Revised VI

0 포인트
4/8 메시지
3,403 조회수
솔루션
주제 작성자 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!

5/8 메시지
3,379 조회수

@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 포인트
6/8 메시지
3,273 조회수

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 포인트
7/8 메시지
3,191 조회수

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



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
8/8 메시지
3,182 조회수