Skip to main content
bagonterman
Inspiring
January 10, 2013
Answered

add text to an exsisting text file w/o overwriting

  • January 10, 2013
  • 1 reply
  • 1372 views

I am creating a text file that will tally information from a UI. My hope is that I can add information as buttons are clicked. But when I write to the text file it over writes what is already there. 

myFile.writeln("\r\n",mySFolder,"   ",myCountText.text, );

I am wondering how to append to the text file.

This topic has been closed for replies.
Correct answer Paul Riggott

Here is an example...

var Log =File(Folder.desktop +"/LogFile.txt");
Log.open('w'); //open a new document
Log.writeln("This is a log file");
Log.close();

Log.open('e'); //open for append
Log.seek(0,2); //seek to end of file
Log.writeln("Write text to re-opened file");
Log.close();


1 reply

Paul Riggott
Paul RiggottCorrect answer
Inspiring
January 10, 2013

Here is an example...

var Log =File(Folder.desktop +"/LogFile.txt");
Log.open('w'); //open a new document
Log.writeln("This is a log file");
Log.close();

Log.open('e'); //open for append
Log.seek(0,2); //seek to end of file
Log.writeln("Write text to re-opened file");
Log.close();


Inspiring
January 10, 2013

Paul e is edit… a is append… Your version however works pre-cs4 versions…

Paul Riggott
Inspiring
January 10, 2013

Thanks Mark, like me it's OLD