Is there any easy way to open a file and append data to the end of it instead of overwriting it ?
Essentially I would like to open an already existing text file, move to the end position and start writing data on a new line at the end of the file using WriteLine() ?
Edit forgot so say I'm doing this to try to get to the end of the file
OpenFile (1,"DB.CSV",#MODE_WRITE)
Seek(1,#EOF)
DebugPrint(FilePos(1))
Always Returns 0 as the filepos
Edit never mind I just discovered i am using the wrong #mode, should be #MODE_READWRITE
Append data to a file
Append data to a file
Last edited by JurassicC on Thu May 15, 2014 10:59 pm, edited 1 time in total.
AmigaOne X1000 - RadeonHD 7870, 4GB RAM - AmigaOS 4.1ß
AmigaOne X5000 - Radeon R7 250, 2GB RAM - AmigaOS 4.1ß
AmigaOne X5000 - Radeon R7 250, 2GB RAM - AmigaOS 4.1ß
- airsoftsoftwair
- Posts: 5433
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: Append data to a file
So do I get that from reading the file length first or do a readchr until I get to the EOF and use the amount of characters for Seek()
I'm doing to do this now is there a better way to get the EOF position.
OpenFile (2,"DB.CSV",#MODE_READWRITE)
MyFilePos = 0
While Not EOF(2)
Seek(2,MyFilePos)
MyFilePos = MyFilePos +1
Wend
DebugPrint(MyFilePos)
I'm doing to do this now is there a better way to get the EOF position.
OpenFile (2,"DB.CSV",#MODE_READWRITE)
MyFilePos = 0
While Not EOF(2)
Seek(2,MyFilePos)
MyFilePos = MyFilePos +1
Wend
DebugPrint(MyFilePos)
AmigaOne X1000 - RadeonHD 7870, 4GB RAM - AmigaOS 4.1ß
AmigaOne X5000 - Radeon R7 250, 2GB RAM - AmigaOS 4.1ß
AmigaOne X5000 - Radeon R7 250, 2GB RAM - AmigaOS 4.1ß
Re: Append data to a file
Got it working if I close the file and reopen and seek to MyFilePos-1 it all good and I'm appending data.
Cheers for the Tips
Cheers for the Tips
AmigaOne X1000 - RadeonHD 7870, 4GB RAM - AmigaOS 4.1ß
AmigaOne X5000 - Radeon R7 250, 2GB RAM - AmigaOS 4.1ß
AmigaOne X5000 - Radeon R7 250, 2GB RAM - AmigaOS 4.1ß
- airsoftsoftwair
- Posts: 5433
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: Append data to a file
Code: Select all
MyFilePos = 0
While Not EOF(2)
Seek(2,MyFilePos)
MyFilePos = MyFilePos +1
Wend