From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
03-20-2012 05:32 PM
Hello, I got a problem with open/replace/create function. Could you please clarify each function how it works? As you can see in my file, I try to save into the specified file path. The values appear in the text file but when I change some values in the data mainstream, it replaces the old value it has been. I want to have the whole data in one file till I close it and open another file for the operation.
How can I do it??
Thank you
Solved! Go to Solution.
03-20-2012 11:11 PM
You are opening and closing the file on every loop iteration. Are you sure that is what you want to do?
The reason the data is getting replaced is that when you open the file, the file pointer is at the beginning, so the data gets put there. If you want to put new data at the end, then you need to set the file position to the end of the file before you write the new data.
03-21-2012 03:45 AM
So I should take "close file" out from the big loop?
03-21-2012 04:30 AM
What did you mean by "set the file position at the end of the file"?? Which block should to move to where?
03-21-2012 08:22 AM
Search the palettes for "Set File Position".
Take both the open and the close file VI's out of the loop.
03-21-2012 08:29 AM
i think its in programming->file io-> advanced file functions
03-21-2012 08:44 AM
Hi,
I can't see your VI as it is in a newer version of LabVIEW than I have, so if you want any more specific help you'll need to save the VI as a previous version. (File -> Save as previous version) I have LabView 2009.
However, I have made a quick little example you could use. You don't need to use Set File Position if you use Shift Registers, as shown in the attached picture.
David.
03-21-2012 08:52 AM
That is a good simple example of how to open the file, write to it in a loop, and close it afterwards.
But shift registers have nothing to do with why you don't need to set the file position. You don't need to set the file position because when the file remains open, the file functions know that the file position is after the data it last wrote out. Closing and reopening a file causes the file position to be reset to the beginning of the file.
03-21-2012 08:55 AM
Oh you're right. Sorry, didn't think my answer through 🙂
03-21-2012 10:03 AM
here we go the 2009 version. I tried to take all out from the loop. it seems working without using the set file position.