LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to save a file?

Hi all. I want to read the characters from a file, modify the string and save the file. My vi it's a simple "Read characters from file.vi" -> "Search and replace string" -> "Write characters to file". The problem is it doesn't work. I think I must close the file before. But "Close file" requires the refnum of the file. How can I get it?
0 Kudos
Message 1 of 3
(2,679 Views)
Your algorithm sounds fine. Can you explain more on why it doesn't work? Did you receive any error message? The file should already been closed in the "Read characters from file.vi". You don't need to put another close file vi.

Some things you might want to check:
1. Make sure your program has a good dataflow. You can wire the output "new file path" in the "Read characters from file.vi" to the input "file path" of the write characters to file vi. That way you make sure you write the file after it's been read. Or you can use a sequence structure to make sure of that.

2. If those are the two VIs you use, then you should receive a dialog asking whether you wish to replace the original file or not. You can use lower level VIs to disable the dialog.

Hope this
helps,
Dan
Message 2 of 3
(2,679 Views)
Thank you, I improved the dataflow and now it works.
0 Kudos
Message 3 of 3
(2,679 Views)