LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Adding to text files

Solved!
Go to solution

Hi All,

 

I want to insert characters into the middle of a text file without overwriting the characters that are already there.  The "Write to Text File" function replaces the old characters with the new ones.  Is there a way to insert the new characters into position and move the old characters further out so that the file becomes longer as a function of the characters you add?

 

Thanks,

 

FB

Forbes Black
Lapsed CLAD, LV 5 - LV 2022 (Yeah, I'm that old...)
0 Kudos
Message 1 of 6
(2,850 Views)

No, you cannot insert data into the middle of a file on disk.  You'll need to read in anything after the part that you want to move, add the new characters, then append the previous data.  If the file is not huge, it is probably easier to read the entire file into a string, make the changes, and write it all back out again.

Message 2 of 6
(2,847 Views)
Solution
Accepted by topic author diarmaede

is this what you meant?

text insert.png

0 Kudos
Message 3 of 6
(2,837 Views)

Apok,

 

I do believe that is in effect what he is asking for.  But he wants that to be done with the file located on the disk drive.  The problem with your example is that it doesn't show any of the file handling functions.

0 Kudos
Message 4 of 6
(2,831 Views)

well, I didnt want to solve it for him...Smiley Wink

0 Kudos
Message 5 of 6
(2,829 Views)

Combining natand and apok's advice will give me what I need.  Thanks, all.

Forbes Black
Lapsed CLAD, LV 5 - LV 2022 (Yeah, I'm that old...)
0 Kudos
Message 6 of 6
(2,815 Views)