Author Topic: openforAppend Help  (Read 851 times)

Ok so I am adding data to a file and I want it to start on a new line. This is what I do:
Code: [Select]
%file.writeLine(%target SPC %m SPC %a SPC %sa SPC %m SPC %r SPC %d);

It does it correctly but it puts it on the same line as the previous data in the file so it shows up:
Quote
(PreviousData)
(PreviousData)
(PreviousData)
(PreviousData)(NewData)

and I want it to be:
Quote
(PreviousData)
(PreviousData)
(PreviousData)
(PreviousData)
(NewData)

gonna take a stab and guess that you can add \n to the start of every line to make a newline.

gonna take a stab and guess that you can add \n to the start of every line to make a newline.
yeah but that shouldn't be needed. openForAppend should be making new lines on its own.

EDIT:
are you closing the file object when you're done with it?

Show us the code you're using to write the previous data.

Make sure that after your done writing in a file you close it with .close(); and then delete the file object with .delete();

Make sure that after your done writing in a file you close it with .close(); and then delete the file object with .delete();

Just delete it, it'll close it automatically.

Just delete it, it'll close it automatically.
Oh, good to know.

Code: [Select]
void FileObject::writeLine(const U8 *line)
{
   stream.write(dStrlen((const char *) line), line);
   stream.write(2, "\r\n");
}
the writeLine function always ends with "\r\n"
so the reason its appearing on the same line is probably because you wrote in the initial lines, if you are going to do so make sure that after the last entery you leave a line break

Just delete it, it'll close it automatically.
Really? Never knew that.