Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

add text to an exsisting text file w/o overwriting

Engaged ,
Jan 10, 2013 Jan 10, 2013

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.

TOPICS
Scripting
1.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Valorous Hero , Jan 10, 2013 Jan 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();


Translate
Valorous Hero ,
Jan 10, 2013 Jan 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();


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Jan 10, 2013 Jan 10, 2013

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jan 10, 2013 Jan 10, 2013

Thanks Mark, like me it's OLD

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 10, 2013 Jan 10, 2013

When I used 'a' it did not work. I am using CS5 Bridge.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jan 10, 2013 Jan 10, 2013

This works with Windows 7 and Bridge CS5.

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('a'); //open for append
Log.writeln("Write text to re-opened file");
Log.close();

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 10, 2013 Jan 10, 2013
LATEST

I am using OS 10.6.8.  'e' works for me. I am wondering if I will have any trouble when I switch to Windows 7?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 10, 2013 Jan 10, 2013

Thank you very much for your help!!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines