Reading/Writing files

Blitz3D Forums/Blitz3D Beginners Area/Reading/Writing files

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Yes, you should open the file with OpenFile, and then seek to the end of the file using SeekFile:
fname$ = "test2.dat"

SeedRnd(MilliSecs())

;test if file exists
test = FileType(fname$)

;if it doesn't
If Not test Then
		
	;createfile
	file = WriteFile(fname$)

;if it does		
Else
	
	;open file
	file = OpenFile(fname$)
	;seek to end of file
	SeekFile file, FileSize(fname$)
	
End If

;add line and close file
WriteLine file, "testline " + Rand(255) 
CloseFile file

;print file
file  = ReadFile(fname$)
While Not(Eof(file))

	Print ReadLine(file)
	
Wend
CloseFile file

WaitKey()
End