Reading tabled data

BlitzMax Forums/BlitzMax Beginners Area/Reading tabled data

Ok, I assume you will want to read the file, which has certain seperators to show, when a new entry is there?

So something like this should work:
Function ReadDString:String(stream:TStream,seperator:Byte[])
 If stream = Null
  Return ""
 EndIf
 Local b:byte
 Local s:String
 While Eof(stream) = False
  b = ReadByte(stream)
  For Local i = 0 Until seperator.length
   If b = seperator[i]
    Return s
   EndIf
  Next
  s :+ Chr(b)
 Wend
End Function
You then need to open a file, and supply that and a list of seperator values to it...
Something like this:
myfile = ReadFile("hello.txt")
Repeat
 Local s:string = ReadDString(myfile,[Asc(" "),10])
 Print s
Until s = ""
CloseFile(myfile)
It's not tested, so it might be buggy :)