Author Topic: WriteLine  (Read 7205 times)

I'm looking for a %file function that adds text to the end of the file then saves then next time it just adds on without overwriting. Also, where's a function or something that aborts the script?

Didn't I already tell you to look at the persistence script?  All the file writing information you need is there.

I did, I can't find the command to add-on or simply abort the script.

Well, you'd have to use two files. One file that actually gets executed and a temp file.  The temp file would be used when you just want to add a line to it.  So on the line addition, you'd read in all the lines from the exec file until you get to a certain point, then write them to the temp file and add your new line.  then close off the file and write all the temp content to the exec'd file.

About the abort, I'm sure it's possible but I'm not gonna spell that out for you.
« Last Edit: February 27, 2007, 06:30:52 PM by Trader »


Not if you're wanting to keep adding lines to the same file.  You may be able to code the deletion of the temp file in between uses though, I don't remember.


I'll see what I can do when I get home; I'm at work now.

Badspot

  • Administrator
Code: [Select]
%file = new FileObject();
%file.openForAppend(filename);
%file.writeLine("whatever");
%file.close();
%file.delete();

Wow. I just noticed I suck at scripting.

Code: [Select]
%file = new FileObject();
%file.openForAppend(filename);
%file.writeLine("whatever");
%file.close();
%file.delete();

So, I get that, that writes to a file, but how do I add it on to another file

I'm not sure that I understand your request.

Badspot

  • Administrator
What do you want to do? combine two files?  openForAppend() will make writeLine() add lines to the end of the file. 

Oh, I get it now. Thanks.

Wow. I just noticed I suck at scripting.

Only just now?

And Trader: I thought "TorqueScript was your bitch"? Haha.
« Last Edit: February 28, 2007, 07:09:53 AM by Ephialtes »