each, and I was using ReadString to grab the bytes and then using Left to
check for specific values, and it occurred to me that an optional length
parameter would be handy, much like how PeekS works. Because if the
file I'm reading with ReadString has a LOT of text before an end-of-line
character is found, then the read is using far more memory than it should
be (I'm actually only checking the first 5 bytes of the file, you see).
Or, ideally, I'd like to see a command for files something like this:
text$=ReadOffsetString(#file,startpos,length)
This would be very handy for parsing files where the information needed
is always located in the same offset positions. This is what I'm using now,
but surely a native command would be much faster?

Code: Select all
Procedure.s ReadOffsetString(file$,startpos,length)
f=ReadFile(#PB_Any,file$)
If f
If startpos<>0 : FileSeek(f,startpos) : EndIf
text$=ReadString(f) : CloseFile(f)
If length<>0 : text$=Left(text$,length) : EndIf
EndIf
ProcedureReturn text$
EndProcedure