04-08-2009 10:43 AM
Hello, I have a give text file and want to add a string into it.
the file looks like:
"@A ....
data...
@B ..
data...
..."
I want to add data after @X,
If the text file already have @X section, I overwrite it.
If not, I add a section @X and then add data.
How do I do that?
Too bad I can not find a search function in labview that move my refnum to the matched location...
04-08-2009 11:59 AM
I would suggest (if the file isn't huge):
1.) Use the "read text file" vi to read a few bytes at a time until you find your search string "@X"
2.) Use the "get file position" vi to determine the offset.
3.) Read the remainder of the file into a text buffer.
4.) Write the new data starting at the offset and then write back the text in the buffer. This should work since the "write text file" vi overwrites any remaining data.
Just an idea... there may be better methods out there.