WriteLine not doing what it says on the packet

BlitzMax Forums/BlitzMax Beginners Area/WriteLine not doing what it says on the packet

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.

I'm really sorry but your code then must be trashed.
This code works without any problem on Windows:

Strict

Local Chainsaw:TStream = OpenFile("test.txt")
Local RLine:String = "Testline 3"

If Not Chainsaw
	chainsaw = WriteFile("test.txt")
	chainsaw.writeline("Testline 1")
	chainsaw.writeline("Testline 2")
	chainsaw.writeline("Testline 3")
EndIf

Print StreamPos(Chainsaw)
SeekStream(Chainsaw,StreamPos(Chainsaw)-(Len(RLine)+2)) 'Move the stream position back the length of the line, plus an extra 2 for the "new line" character
Print StreamPos(Chainsaw)
RLine = Left(RLine,Len(RLine)-1) 'Chop the last character (0) off of RLine
RLine = RLine + "1" 'Replace it with a 1
Chainsaw.WriteLine(RLine) 'Write the line back again
Print StreamPos(Chainsaw)

Chainsaw.close()



Keep in mind that with OSX or Linux, it would be +1 on the SeekStream as those have only a single char "newline" representation (either cr or lf, don't know anymore), not a double char (cr + lf) as windows