LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Write to file vi always appends

Hiya,
I've got the following vi (see below). Every time the while loop is executed an element(value) gets added to the array. If the while loop is stopped the array gets written to a file. That works fine for the first execution. However when I re-run the program it seems that the old values remain and the new values are appended. I don't want this. I want a file with the results of every single execution.
It seems as though the array doesn't get re-initialized. Only closing the program and re-opening it helps.
What can I do? HOw can I delete the 'buffer'?

Cheers
0 Kudos
Message 1 of 7
(3,169 Views)
I can't open your VI (I don't have LV 7) but it sounds like you are forgetting to initialise a shift register before entering the loop. To do this, simply connect an empty array (assuming your shift register is an array) to the shift register on the left-hand side of the loop. This will re-initialise the register each time the loop starts (But not while looping).

Try simple right-clicking the left-hand register and choosing "create constant".

Hope this helps

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
Message 2 of 7
(3,169 Views)
Hello,

I have tried to open your VI, but the "ScobeSUB.vi" is missing. Maybe it is in an Add-On which is not installed on my PC.
However, in the Labview Example Finder you can find the "Write to Text File.vi" which is similar to your problem.

I hope, this will help. Good luck.

Regards
Thomas D.
0 Kudos
Message 3 of 7
(3,169 Views)
Hi!

Right click the left shift register and create->make constant so you can initialize the shift register.

That can help.

Neuvos
Message 4 of 7
(3,169 Views)
Thanks Thomas for your answer.
The point is that the SubVI is just there to indicate an output.
The problem lies in the initialization of the array!
0 Kudos
Message 5 of 7
(3,169 Views)
Hello,

- I've modified a little bit your VI to make it work as you wanted.
- I've added a little library in which you could find examples of what could be done with files.

Hope this helps ! (even if comments and descriptions are in French)

Ecraser means replace (file)
Concaténer means append (to file)

Julien
Download All
0 Kudos
Message 6 of 7
(3,169 Views)
Thanks all, I resolved the problem with simpoly putting a "initialize array" at the start of the while loop!
0 Kudos
Message 7 of 7
(3,169 Views)