writing string to stream

BlitzMax Forums/BlitzMax Programming/writing string to stream

ninjarat(Posted 2006) [#1]
Hello, all. According to my dad, (also a programmer,) what I am about to show you is NOT completely origonal, but I still made it up without knowing about it, so I'm kinda proud :D.

I'm posting an example that can manage a high scores list with a hundred entries (haven't written the sorter, but the relevant stream management is there).

Here's the idea:

When writing a string to a stream, there are three different methods.

The first two methods are: write strings that are always the same number of bytes, or using "tehStream.WriteLine(str$)" to just write a single line of text with a line terminator byte at the end.

My method is to write a value (a byte is best) before the string that says how long it will be, then read it based on the length stated.

There! Ooh, I think my ego just went from shriveled prune to monkey carcass (slightly better than the prune one)! Oops, lost it again. Damn!

Edit: Okay it's up in the code archive. It's called "High Score Type"


ninjarat(Posted 2006) [#2]
Here's a simplified / modularized version.