Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ATLINE() bug and workaround?
Message
From
22/09/1998 15:16:33
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00138760
Message ID:
00139586
Views:
37
>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.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Reply
Map
View

Click here to load this message in the networking platform