Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can I SEEK for nearest matched record in CURSOR?
Message
From
29/07/1999 13:57:34
 
 
To
29/07/1999 13:45:39
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00247560
Message ID:
00247811
Views:
16
Its either that or keep doing locates with ever shrink length of string until you get a hit.

Like this:
lcmysearch = this.value
lnstartlen = len(alltrim(lcmysearch))
locate for field = lcmysearch
if !found() then
for lncounter = lnstartlen - 1 to 1 step -1
locate all for field = left(lcmysearch, lncounter)
if found() then
exit
endif
next
endif
if !found() then
* the user was a looser and couldn't even get close!
endif

of course, you might like them to be at the beginning of the R's if they entered Q's, but I'll leave that as a excercise for the student :-)


>Thanks to Bill, Bruce, Walter, Vinod and Ed.
>
>I think Bruce and Ed got my situation. I'm using the SQL Select to make some searches and output them to a form. So I created a temporary cursor for the ControlSource on the form's control. And I did all the things well when the user enters a valid record to search for. Just that, if the user enters an invalid record, I need to Set Near On to get the nearest matched record. But Set Near On will require either Seek or Find where I need to create a temporary index files.
>
>Maybe the solution is I just create an index tag using Index On.. and then delete the index files after closing the form. Got a better way?
>Gan
>
>>>All,
>>>
>>>I have a SQL Select for putting all my records in a cursor, and I need to do some search in the cursor.
>>>
>>>I''m be able to use LOCATE to look for a certain record but couldn't use SEEK or FIND because both of them need an index tag. I need to search for the nearest matched record in the cursor in case LOCATE fails.
>>>
>>>Any solution for this?
>>>
>>>Thanks.
>>>Gan
>>
>>In addition to what the others have said, you might want to look at SET NEAR and SET EXACT for this situation.
>>
>>Bill
--Todd Sherman
-Wake Up! Smell the Coffee!
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform