>An alternative to arrays:
>
>
>#DEFINE CRLF CHR(13)+CHR(10)
>LOCAL lcText, lnNumLines, lnLine, lcLine
>lcText = CRLF + FILETOSTR("myfile.txt")
>IF RIGHT(lcText,2) = CRLF
> lnNumLines = OCCURS(CRLF,lcText) - 1
>ELSE
> lnNumLines = OCCURS(CRLF,lcText)
>ENDIF
>FOR lnLine=1 TO lnNumLines
> lcLine = STREXTRACT(lcText,CRLF,CRLF,lnLine,2)
> ? lcLine
>ENDFOR
>
>
>The CRLF is added to the beginning to allow STREXTRACT to extract the first line.
Greg,
As per CC, here is my idea:
1) It'd fail if file has a single line with no CRLF in it (or last line has no CRLF and missed).
2) StrExtract() would be slow (needs to locate the occurence on each call).
PS: I don't understand why he needs an alternative to arrays (or fgets() - if max line length is not over 8192). Fgets() is the ultimate line reading IMHO.
Cetin