Having a problem doing a simple write to a text file using the Lineout
function. I want to write a word, say "DOWN", on the first line (or
optionally replace any existing first line) of the text file. So I do:
CALL Lineout "txtfile.txt", "DOWN", 1
This works fine when the text file is empty. It also works fine if an existing
first line is 1-6 characters. But from the 7th character and forward, these
characters are moved down to line 2 when doing the Lineout. So if the text
file initially is one line with one word;
, after doing the Lineout instruction above the text file looks like:
Most likely you have the order mixed up or have run this multiple times. The
way I got the same results is to line out "WAITING" then line out "DOWN". This
produces the file like you mentioned.
What is really happening here is the first call to lineout implies opening the
file for appending. Then by telling lineout you want to move the position to
the beginning of the file (the third argument). What in effect happens is you
overwrite the first 6 characters of the file (which at this point contains
"WAITING") with "DOWNG".
I usually recommend using all of the stream commands (open then
lineout/linein/charout/charin then close), YMMV.
Log in to post a comment.