Streams and Text Streams

BlitzMax Forums/BlitzMax Beginners Area/Streams and Text Streams

vinians(Posted 2010) [#1]
Hey guys Im again!
So, I want to read a text and a binary file. I was reading the manual and about streams. Whats the difference between TStream and a Text Stream? Can I use TStream to read a text file or I really need Text Stream for this, Im a little confused..
Can you guys guive-me a example? Because I want to know the right way to do this.
Thanks in advance!


Jesse(Posted 2010) [#2]
personally all I have ever used is tstream sense I haven't found the need for anything else.
you can readline, readstring, readbyte, readint... That is basically all I ever need. read line reads a text file as written in notepad, reads it line by line. readstring reads a set of bytes and interprets them as chars. while the others read binary bytes.


vinians(Posted 2010) [#3]
Thanks a lot, I tryed and worked


ima747(Posted 2010) [#4]
I believe the only real advantage of a text stream over a Tstream is UTF8 encoding on text streams which means you can store characters out of range of the ASCII table... but you can also UTF8 encode a TStream, though your results may not be the same...

I always use TStreams myself. But I did have to spin my own text encoder for things like file paths so they wouldn't get eaten if they had weird characters in them...

If you're only working with your own data and perfect external representations (like a file path) arn't needed then TStream with WriteLine would be the way I would (and usually do) go, since you can tack on other stuff as you need it (such as ints, and banks etc.)