06-28-2021 05:28 AM
Hello Folks,
I need help from you.
This is what I’m trying to do:
Whenever I save the .txt file, first, it will clear my current file data and then save new data.
It can be a simple solution, but unfortunately, I could not be able to get it.
Appreciate your effort.
- Reduanul
Solved! Go to Solution.
06-28-2021 05:38 AM
Hi REDUANUL,
@REDUANUL wrote:
Whenever I save the .txt file, first, it will clear my current file data and then save new data.
It can be a simple solution, but unfortunately, I could not be able to get it.
When you want to append data to a file then you need to append that data - instead of overwriting the file or recreate it!
Btw. when there is a problem in YOUR code then you should attach YOUR code. (We cannot debug text/images using LabVIEW…)
06-28-2021 06:02 AM
@REDUANUL wrote:
This is what I’m trying to do:
Whenever I save the .txt file, first, it will clear my current file data and then save new data.
So your goal is to replace or create your file. There is an input on the Open/Create/Replace File node called "operation" where you could set that.
06-28-2021 09:19 AM
Hello GerdW,
Here are my subVI snipped.
First, I have created a file. After one execution file is being replaced, each time string values are saved but with existing data. Probably here, I need to make some changes (if I didn't get you wrong). But not getting what will be the changes!
06-28-2021 09:25 AM
Hello crossrulz,
Yes, I did it.
Here what I did:
Everything works for the initial saving operation, but when the second time (and later on) I am saving, data is adding with exiting string values.
06-28-2021 09:58 AM
You are placing the file pointer to the end of the file therefore you are simply appending the data. Don't set the file position and see if you get your desired results.
06-28-2021 11:08 AM
Hello Mark Yedinak,
I tried it but not working. Same thing happening (appending with existing file) 😞
06-28-2021 01:21 PM
If you are replacing or creating a file, there is no reason to set the file pointer to the end.
06-28-2021 02:06 PM
Hi Reduanul,
@REDUANUL wrote:
First, I have created a file. After one execution file is being replaced, each time string values are saved but with existing data. Probably here, I need to make some changes (if I didn't get you wrong). But not getting what will be the changes!
What is your goal?
Do you want to append new data to an already existing file?
Or do you want to create a new "fresh" file with each run of that VI, "deleting" the old content and only write the new data to the file?
Your explanations aren't clear until now (IMHO)…
06-28-2021 04:11 PM
Hello GerdW,
Here is my explanation:
I have created a file as of now. But want to append new data to an already existing file by "deleting" the old content and only write the new data to the existing file.
I hope now it's clear.