TextFile

Blitz3D Forums/Blitz3D Programming/TextFile

Amanda Dearheart(Posted 2012) [#1]
I'm tryiing to create a simple text file to use as a debug log for my projects.
The problem I'm having is that it
1. leaves '0' characters at the beginning of a line. I want them removed!
2. prints all strings on the same line. I want them on seperate lines as evidenced by the chr$(13) instruction in the M$ DebugFile function. I've tried both with the $ sign and without the sign. It doesn't seem to work, neither does the bell symbol?




Last edited 2012

Last edited 2012

Last edited 2012


Floyd(Posted 2012) [#2]
WriteString is a Blitz-specific format which writes a four byte integer ( the length of the string ) followed by the actual string.

WriteLine ( and the corresponding ReadLine ) automatically use the Windows end of line marker. By the way that's CR-LF, or ASCII 13 and 10.


PowerPC603(Posted 2012) [#3]
Like Floyd suggests, use WriteLine to save your text onto a line in your file.
It automatically adds the end-line characters to your text.

When you use WriteString, this also adds some extra info in front of your text to indicate the length of the text you've written, that may be the "0" character you see in your files. This length is 4 bytes long.
This would be needed if you use ReadString in your file.
ReadString would first read the 4 bytes to know how many bytes to read for the actual string.

I don't get why you use functions the way you've posted above.
For the FreeFile function, you specify a parameter in the form of a string (PrgDebug$), but you don't use it inside the function to close the specified file.
Perhaps this is different in your actual code and you've posted only a small part of it to show the problem.