today i needed an easy way to save and reload strings which contained #LF$, #CR$ and even #CRLF$. With the built-in WriteString() method one can save the string to file, but reloading with ReadString() will fail because the string will be split into multiple pieces (lines). Therefore i wrote the following procedures to write strings and reload them exactly as they have been written.
Code: Select all
Procedure WriteText(File, Text.s)
;write a text including linefeeds to a file
Protected l.l = Len(Text)
WriteLong(File, l)
WriteData(File, @Text, l)
EndProcedure
Procedure.s ReadText(File)
;reads a text including linefeads to a file
Protected l.l = ReadLong(File)
Protected s.s = Space(l)
ReadData(File, @s, l)
ProcedureReturn s
EndProcedure
Best regards
Uwe