Readstring()

BlitzMax Forums/BlitzMax Beginners Area/Readstring()

Surely theres a way to simply read a string from a file without knowing its actual length!!! if not im gonna be real dissapointed with bmax!
No, not just in BlitzMAX, but in general. There are two ways to represent a string in programming languages. In general, these methods all involve a starting address and one of the following:

- A fixed size string (one which has 'n' length, regardless of how many characters it actually has). This requires no additional data.

- An 'n' length string, which needs to know the exact length of a string. This requires you to store or know the exact length of the string (which seems like the case you're struggling with and what ReadString/WriteString relies on).

- A terminated string, which has some sort of terminating character to indicate the end of the string. Traditionally these are 'null terminated' by the ASCII value '0' in programming languages, or CR and/or LF characeters in plain ASCII text files (and what ReadLine/WriteLine does).

Unfortunately that would be ok if it was all text but what about reading out my integer and byte values as well?
Make sure you read it in the same sequence as you write it.