Page 1 of 1

[07 Sep 2006] Help with Seek()

Posted: Sat Jun 13, 2020 5:31 pm
by NathanH
Note: This is an archived post that was originally sent to the Hollywood mailing list on Thu, 7 Sep 2006 20:50:29 -0600

Hi,

I'm trying to append data to the end of an existing file and thought that Seek() was the ticket. I thought that all I would have to do was the following:

Code: Select all

openfile(1,"RAM:Test",#MODE_WRITE)
writeline(1,"This is line 1")
closefile(1)

openfile(1,"RAM:Test",#MODE_WRITE)
seek(1,#EOF)
writeline(1,"This is line 2")
closefile(1)

openfile(1,"RAM:Test",#MODE_READ)
debugprint(readline(1))
debugprint(readline(1))
closefile(1)
The second readline causes a "Beyond EOF" Error and RAM:Test file only consists of the phrase "This is line 2". Any help would be appreciated. Thanks!

Nathan

[12 Sep 2006] Re: Help with Seek()

Posted: Sat Jun 13, 2020 5:31 pm
by airsoftsoftwair
Note: This is an archived post that was originally sent to the Hollywood mailing list on Tue, 12 Sep 2006 14:25:51 +0200 (CEST)

Hi,

sorry for the delay. I'm on vacation currently and do not have Internet access every day.

To answer your question: You need to remove Seek(1, #EOF), then it will work. WriteLine() will automatically append the line to your file.