Discussion:
Unable to force overwrite when writing to text file
(too old to reply)
GTurnipseed
2007-10-19 16:10:06 UTC
Permalink
Hi, all.  I'm trying to design a user interface for modifying configuration files.  The user is supposed to be able to open the file, make changes, and then press Commit, and the program *should* completely overwrite the file with the new data.  Instead, it is appending all of the new data to the end of the existing file.  I've attached the saving VI I've got, and any help would be appreciated.  I've tried several combinations, but with no luck so far:
 
1. open first, with "replace or create", then write, then close
2. open first, with "replace or create", with "write only," then write, then close
3. don't open first, just write to text file
4. open first, with "replace or create", then set file position, mode "start", offset 0, then write, then close.
 
None of these have worked for me.  Is this a glitch with LabVIEW, or is there some combination I missed?  I've read the examples, browsed the Internet for advice, but have come up with nothing.
 
Thanks in advance,
Greg
AnalogKid2DigitalMan
2007-10-19 16:10:06 UTC
Permalink
Greg:
Your vi did not attach
GTurnipseed
2007-10-19 16:40:10 UTC
Permalink
My bad on the file not attaching.  Let's try this again.
 
Yes, I realize it's not so much how I open the file but how I write to it, but I was under the impression that the "open/create/replace" vi was the one that dictated creating a new file, opening a file with read/write/both access, and overwriting files.  It does not appear to be working.  Hopefully the VI will go through this time.
 
Regards,
Greg


Save.vi:
http://forums.ni.com/attachments/ni/170/279235/1/Save.vi
GTurnipseed
2007-10-19 17:10:08 UTC
Permalink
Matthew, you're absolutely right.  I've been so focused on getting the save to not overwrite that I hadn't looked into that.
 
Thanks!
Greg

Loading...