Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Options for avoiding SET FILTER
Message
From
01/02/2000 17:22:03
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00325835
Message ID:
00325852
Views:
18
>In the FPW2.6a version of the app I wrote, I used lots of SET FILTER statements to allow users to find things. Now I now better (yes, I did learn from Jim Booth and company's Top Ten Stupid VFP Coding list!).
>
>What I am trying to do is implement a search and filter class that will let the user enter a phrase and have it search the document titles for that phrase (a CONTAINS search)
>
>In the old days it was:
>
>use q:\qa\qdms2000\qdms!document
>set filter to m.Searchtext $ title
>brow
>
>
>Now (as I understand it) the way to do this is with an SQL statement:
>
>
>select * from q:\qa\qdms2000\qdms!document where l_cSearchtext $ title into cursor temp
>
>
>and then use this cursor as the basis for the grid's record source?
>

Some things to consider would be to use a parameterized view that could be used; advantages include the ability to change the search item and requery() rather than having to change the grid's recordsource, and the option to make the view updatable.

Using a LIKE clause in the WHERE statement might be attractive, too, since you can use more complex wildcarding than a simple $ - % in a string matches any number of characters, _ exactly one, so:

title LIKE "%SM_TH%"

matches SMITH, SMYTHE, etc,

title like "SM%"

matches anything that starts with SM,

title LIKE "% VFP _"

matches anything that ends in something like "VFP 3", "VFP 5", "VFP 6", etc.

The wildcarding isn't an expensive choice, either, and can work with a parameterized view, plus has the benefit of being portable to a backend database engine.

>I have lots of places where this is used in the app, and I wanted to make sure this is the right approach before starting down the road....
>
>Thanks!
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Reply
Map
View

Click here to load this message in the networking platform