Trouble Appending to file
by Jeff Trier · in Torque Game Engine · 04/29/2003 (7:16 pm) · 1 replies
Hi all,
I am trying to save a variable to the end of a file with this code:
It works with only one flaw. It likes to place an extra blank line after the newly added line.
For example, if the variable was appended to line 22, there would be a new blank line in line 23:
line 22: TestLine
line 23:
Is there a way to keep this new line from being created? This may sound trivial, but when I save multiple lines with this method, it creates gaps between them.
Thanks,
-Jeff
I am trying to save a variable to the end of a file with this code:
function SaveData(%filename, %Data){ // Write Data to end of file
%file = new FileObject();
%file.openforAppend(%filename);
%file.writeLine(""); // Keep from appending to end of last line
%file.writeLine(%Data);
%file.close();
%file.delete();
}
function SaveInfo(){
%SaveData = "TestLine";
%filename = "fps/server/scripts/armies/armyData.cs";
SaveData(%filename, %SaveData);
}It works with only one flaw. It likes to place an extra blank line after the newly added line.
For example, if the variable was appended to line 22, there would be a new blank line in line 23:
line 22: TestLine
line 23:
Is there a way to keep this new line from being created? This may sound trivial, but when I save multiple lines with this method, it creates gaps between them.
Thanks,
-Jeff
About the author
Originally a Classical/Metal musician, I've always been attracted to anything involving computers, including: Networking, PC Building and Repair, software design and coding. I've been involved with game design and development for over 10 years.
Torque Owner Jeff Trier
Simple Distractions Software
Thanks,
-Jeff