New line in Text Document

Blitz3D Forums/Blitz3D Beginners Area/New line in Text Document

The3Leaf(Posted 2012) [#1]
Hello. I'm making md2 animation, but my exporter requires me to have a txt file saying how many frames there are in animation. Thought that was kind of lame since my current animation consists of 240 frames. So I decided to have Blitz write the Text file for me. Here is my code.





Is pretty basic, but it will work. The problem is I can figure out how to start a new line after it writes every frame witch is what I need. I tryed google and found stuff like chr$(13) and chr$(32). I played with that for a bit with no luck other than weird characters and a few spaces. I looked up ASCII codes and also had now luck with that. I'm not very experienced in BlitzBasic and I'm new to programming. This is actually my first bb program to write a file haha. Anyway any help would be appreciated. Thanks.


Yasha(Posted 2012) [#2]
The first thing is that you do not want to use WriteString for this. WriteString prepends the string data with a raw Blitz integer for re-loading purposes, and even this isn't guaranteed to be constant from version to version. It's a binary write operation, not a text write, and not suitable for creating text files.

The command you need is WriteLine. It will write characters only (i.e. a text-mode write operation), and append a newline after the passed string.

In order to write multiple lines with one WriteLine command, you can insert the newline yourself (note that one newline will always be appended by WriteLine regardless of whether you added one to the end of the string). The correct Windows newline string is Chr(13)+Chr(10).

Last edited 2012


The3Leaf(Posted 2012) [#3]
Thanks a ton Yasha. I'm surprised the solution was that simple haha.
My new code is.



And it works perfectly for me. Thanks again.