WriteLine without CRLF

BlitzMax Forums/BlitzMax Beginners Area/WriteLine without CRLF

Glenn Dodd(Posted 2007) [#1]
I have some text in a variable that i need to write to a file. Writeline always puts a CRLF on the end. I need to write the first line WITHOUT the CRLF.
In this code the Header Variable, which comes first in the file, needs to be written without the CRLF.

Any thoughts?

Local files$[]
ChangeDir CurrentDir()+"\ToBeConverted"
files=LoadDir(CurrentDir())

For t$=EachIn files
If Upper(Left(t,3))="FLI" Then
fileIn=OpenFile(t)
DeleteFile("Modified"+t)
fileOut=WriteFile("Modified"+t)

If Not fileIn RuntimeError "could not open the source file"
If Not fileOut RuntimeError "could not open the output file"

header$=Chr(152) + Chr(1) + "CP_FCPS_BOOK"
For i = 1 To 84
header=header+Chr(0)
Next
Write fileOut,header

While Not Eof(fileIn)
datain$=ReadLine(fileIn)
If Upper(Left(datain,1))="D" Or Upper(Left(datain,1))="C" Then
WriteLine fileOut,datain
EndIf
Wend
CloseStream fileIn
CloseStream fileOut
EndIf
Next

Regards
Glenn


Scott Shaver(Posted 2007) [#2]
Local out:TStream = WriteStream(filename)
If Not out RuntimeError "Failed to open a WriteStream to file "+filename
Local mfs:TStream = LittleEndianStream(out)
			
' write the file header
Local fileid:String = "SASMEF"
WriteString(mfs,fileid)



Glenn Dodd(Posted 2007) [#3]
many thanks