Assume your text file contains the following lines:
this is line 1
line 2
my line 3 By hex viewing the file you will find that it looks like this (non hex parts):
this is line 1<crlf>line 2<crlf>my line 3<crlf> <CRLF> is terminating each line line and is (if I remember correctly) hex: 0D0A
If you replace now Line2 by, let's say: " New Line 2", you updated file looks like this:
this is line 1<crlf>new line 2<crlf>ine 3<crlf> Which means you have overwritten the beginning parts of line 3. Lineout is not line sensitive concerning the lenght, it just starts at the beginning of the refered line and writes the line contents, regardless the length of the old line! If you open the file in Notepad you will see:
line 1
new line 2
ine 3
replacing lines in a text file using the LINEOUT command makes only sense if it has the same line length! If you want a reliable update you should first read the entire file into a stem, make you updates in the stem, and file the stem back:
LOADTEXT("MyFile.", file-name)
myfile.2="New Line 2"
LOADTEXT("MyFile.", file-name,"S")
|