Jump to content




fs API: Adding string without deleting previous string in file


3 replies to this topic

#1 moneymaster2012

  • Members
  • 38 posts

Posted 16 March 2017 - 12:15 AM

I need to make a program where the user's input always adds a new line of code (string) to a file. But what I keep getting is each type the user writes a string into a file, the previous code/string is deleted. How do I continually keep adding strings to this one file without the previous code going to trash?

#2 FuzzyLitchi

  • Members
  • 34 posts

Posted 16 March 2017 - 12:22 AM

you want to use
file = fs.open("file_path_here", "a")

"a" being the important part, this appends to the end of the file.

you can then use
file.writeLine("This line is now appended!")
to append to the end of the file.

Edited by FuzzyLitchi, 16 March 2017 - 12:22 AM.


#3 moneymaster2012

  • Members
  • 38 posts

Posted 16 March 2017 - 12:47 AM

View PostFuzzyLitchi, on 16 March 2017 - 12:22 AM, said:

you want to use
file = fs.open("file_path_here", "a")

"a" being the important part, this appends to the end of the file.

you can then use
file.writeLine("This line is now appended!")
to append to the end of the file.
Haha I didn't think of that, thanks. I guess I had trouble because I didn't know what append meant lmao

#4 FuzzyLitchi

  • Members
  • 34 posts

Posted 16 March 2017 - 02:37 PM

You're welcome :)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users