>VFP 6.0 has a new command ATLINE and ATCLINE which is nice for qiuckly getting to a line in a string. This is handy if you need to line based parsing of strings.
>
>Unfortunately there's a bug (feature?) that causes ATLINE to fail if you look for strings that contain CHR(13) or for strings at the end of a line that have trailing spaces:
>
>lcText = "Hi..." + CHR(13)+"Hello World "+CHR(13)+"!"
>? ATCLINE("World ",lcText)
>
>lcText = "Hi..." + CHR(13)+"Hello World "+CHR(13)+"!"
>? ATCLINE("World"+CHR(13),lcText)
>
>Both of the above fail making it impossible to search for an exact
>match that may occur at the end of a line.
>
>Ok, so that's out. Any suggestions on how you could do this
>efficiently? I need to get a line number into a string in order
>to be able to go forward and backwards through the file. Parsing
>with MLINE won't work either, because it'll never retrieve a
>CHR(13) either.
>
>Any ideas how else to get a line pointer?
>
>+++ Rick ---
FoundAt=at(string, longstring) && having given up the line search, here's an absolute search
lastlineend=Rat(chr(13), left(longstring, FoundAt), 2) && two CR's before that position
_mline=lastlineend+1 && this should be the beginning of the next line, unless the last one ended with both cr+lf
LineWhereItIs=mline(LongString,1,_mline) && this should get you the line, if just a pointer is not enough
It's a kludge, and will surely be slower, but I think this should work, at least. Given VFP6's speed with strings, may nobody notice.