>m.go_on = .t.
>do while m.go_on
>m.lineoftext = fgets (handle1,512)
>if left ( m.lineoftext, 11 ) = '##########:'
>m.go_on = .f.
....
>As help says, fgets command should read sequence of bytes until it
>encounters CRLF, it doesn't and stops at 254-byte and divides one line
>into two!!!! It known or not.
>Comments, appreciated.
>Dezider
>--
I remember having trouble with that in the days of FP1.02... and they
didn't change a thing, eh? Well, I don't mind - we who use LL functions
should be old wolves enough to keep such little tricks in our heads.
Besides, I don't trust fgets(), because it expects some kind of a
regular string (i.e. no nulls, ending with cr, lf, or both) but one's
never sure what it might encounter inside. So I prefer writing it like
this:
#define delim chr(13)
m.go_on = .t.
m.buffer=""
do while m.go_on and not feof(handle1)
m.buffer=m.buffer+fread(handle1, 4096)
m.eol=at(delim, m.buffer)
if m.eol>0
m.lineoftext = left(m.buffer, m.eol-1)
m.buffer=subs(m.buffer, m.eol+1)
if left ( m.lineoftext, 11 ) = '##########:'
....etc. It does work a bit faster like this (maybe), but the matter is
it checks for feof() (i don't take existence of final record marker for
granted, the file may be corrupt), and chop my buffer into lines.
FGets() will take nulls as line delimiters, and I've had a case of some
unused fields in some records being filled with null bytes - FGets()
simply dropped the rest of the line. FRead() surely gets your data, and
then you can use simple string manipulation to work with it... and yes,
you have to chop it into lines yourself.