LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Inconsistent For Loop Write.

I have am trying to take data and append it to a file using a for loop. If you look at the picture you would intuitively think that it would write11 lines onto the file, but it alternates between 9 and 10 lines with no apparent pattern or cause. Can anyobody explain this to me please?

0 Kudos
Message 1 of 5
(2,593 Views)

What debugging have you tried?  I would set a breakpoint after each write is complete, and then open the file after each run.  Then you will know what new data was written after each of the 11 write functions execute.

0 Kudos
Message 2 of 5
(2,579 Views)

What is the value of Sweep time control? Why are you starting and clearing task each iteration? Why is threre copypasted code before the loop?

0 Kudos
Message 3 of 5
(2,572 Views)

You don't need to set the file position.  It automatically updates the file position with each write so that you will just keep appending.  The other issue is that when you don't use the File Reference Output of the Write to File, the function will close the file for you.  So it is likely that LabVIEW tells Windows to close the file, but that takes time.  And in that time, you just happen to be able to get more writes in.  I would recommend passing the file reference out of the FOR loop (use a shift register along with the reference coming in) and explicitly using Close File after the FOR loop.


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 4 of 5
(2,566 Views)

What's the idea behind setting the file position?

 

Please attach the VI instead of a picture.

0 Kudos
Message 5 of 5
(2,565 Views)