Skip to main content
bagonterman
Inspiring
ene 10, 2013 3:27 p. m. UTC
Resuelto

add text to an exsisting text file w/o overwriting

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.

Este tema ha sido cerrado para respuestas.
Paul Riggott
Paul RiggottRespuesta
Inspiring
ene 10, 2013 4:06 p. m. UTC

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();


7 respuestas

Paul Riggott
Paul RiggottRespuesta
Inspiring
ene 10, 2013 4:06 p. m. UTC

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();


Traducir
Inspiring
ene 10, 2013 5:19 p. m. UTC

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

Traducir
Paul Riggott
Inspiring
ene 10, 2013 5:25 p. m. UTC

Thanks Mark, like me it's OLD

Traducir