Page 1 of 1

how do i append a text to an existing txt file?

Posted: Tue Jun 07, 2005 2:32 pm
by debaser
well

my application is a notepad that should add to a text file (*.txt) the new comments i write.
i just have a text editor and a "save" button. when i push save it has to add the new text to a specified txt file.

Code: Select all


      OpenFile(0, "appunti.txt")
      WriteString(String$)
      CloseFile(0)
with this code it overwrites everytime the first line....
[/code]

Posted: Tue Jun 07, 2005 2:36 pm
by sec

Code: Select all

  OpenFile(0, "appunti.txt") 
Fileseek(lof())    
  WriteString(String$) 
      CloseFile(0) 
Correct it! thanks D*

Posted: Tue Jun 07, 2005 2:40 pm
by Dare2

Code: Select all

If OpenFile(#_file, "outdoc.txt")
  FileSeek(lof())
  WriteStringN("<< APPENDED >>")
  CloseFile(#_file)
EndIf
Whup - slow typer. As Sec showed.

Posted: Tue Jun 07, 2005 2:40 pm
by Doobrey
Shouldn't it be FileSeek(Lof()) instead of FileSeek(Eof())?

Edit.. beaten to it by Dare2 :roll:

Posted: Tue Jun 07, 2005 2:50 pm
by sec
Doobrey wrote:Shouldn't it be FileSeek(Lof()) instead of FileSeek(Eof())?

Edit.. beaten to it by Dare2 :roll:
my typo .

Posted: Tue Jun 07, 2005 2:56 pm
by Dare2
It's a three-way tie!

:)

Posted: Tue Jun 07, 2005 5:30 pm
by Doobrey
Dare2 wrote:It's a three-way tie!

:)
OK, deathmatch it is then ... :twisted:
Or would you prefer rock,paper,scissors ?

Posted: Tue Jun 07, 2005 5:49 pm
by Dare2
rofl. :D

paper!

Re: how do i append a text to an existing txt file?

Posted: Tue Jun 07, 2005 9:40 pm
by PB