LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to read/write strings to a file

Hi,
I have a text file with 4 lines in it. I need to be able to read the 4 lines and display them as default values for 4 string controls , then whatever the user enters as the values (changing them or not) I want to take the 4 separate strings and write them to the same file replacing the original 4 lines with the new 4. Any ideas would be appreciated.
Thanks
0 Kudos
Message 1 of 3
(3,312 Views)
You will have to separate the "lines" with something. A carriage return and or line feed is definitely suitable, as it does make the text file easier to read.

All you do is parse out the text with any of a number of tools/methods available in LabVIEW. Read the file, parse out your text and populate your controls. Then to save the text to files, concatenate the String Controls with separation characters (\r, \n, or both) and write to text file.

Check through the LabVIEW examples, everything you need should be there.
0 Kudos
Message 2 of 3
(3,312 Views)
Here is a little example program I wrote. It is nothing fancy, but it does what you asked. It reads the characters from a file and will write only four lines to a file. If you do not like the dialog box when writing, you will need to open write characters to file.vi and edit it.

Jeremy
0 Kudos
Message 3 of 3
(3,312 Views)