Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Searching for a substring in a field - fastest way
Message
From
12/03/2017 15:08:23
John Ryan
Captain-Cooker Appreciation Society
Taumata Whakatangi ..., New Zealand
 
 
To
09/03/2017 14:30:30
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01648880
Message ID:
01648951
Views:
57
>>Is there a quicker way?

LIKE is partly Rushmore optimizable from memory- though it's less likely if your string can be anywhere in the field.
myfleld="Test1Test2"
? LIKE("*Test1*",myfleld)
? LIKE("*Test2*",myfield)
Especially if there's only a few likely matches, I agree with the suggestion to extract matches to a cursor. SET FILTER in a Grid can be terribly slow...

The other thing you might try, is the old PHDBase that still works in VFP9. http://fox.wikis.com/wc.dll?Wiki~PhdBase Pulling records with a string expression can be nearly instantaneous, even with hundreds of thousands of records. Also it has a really good fuzzy search in case somebody misspells MacAdam (sic) and you need to find that needle in a haystack! I'm not sure whether you can still buy it- its author, Jim Korenthal, seemed to change direction many years ago.
"... They ne'er cared for us
yet: suffer us to famish, and their store-houses
crammed with grain; make edicts for usury, to
support usurers; repeal daily any wholesome act
established against the rich, and provide more
piercing statutes daily, to chain up and restrain
the poor. If the wars eat us not up, they will; and
there's all the love they bear us.
"
-- Shakespeare: Coriolanus, Act 1, scene 1
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform