LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Overwrite specific value on .txt file

Hello

Does any one know how to overwrite specific values in a .txt file?

 

here's and example of what i need:

Example1.jpg

I just want to replace the numbers 1 and 2 every time I run my code, the rest remain the same.

this is the part of the code Im using

code1.jpg

 

thanks!

 

 

0 Kudos
Message 1 of 3
(2,142 Views)

The easiest way would be to read the file into an array, change the values and then write the complete file.

0 Kudos
Message 2 of 3
(2,124 Views)

Hello Tokighy,

 

What Bryan mentions is a good approach, you can also check the Write to Text File and Read from Text File.vi in the Find Examples section in LabVIEW, you can take the output from the Read from Text File (having as input your .txt file) and then use either Replace Substring or Search and Replace String functions from the String palette.

 

http://zone.ni.com/reference/en-XX/help/371361H-01/glang/search_and_replace_string/

http://zone.ni.com/reference/en-XX/help/371361J-01/glang/replace_substring/

 

Hope you find this information useful!

 

Regards, 

Luis CT
0 Kudos
Message 3 of 3
(2,097 Views)