General information
Category:
Databases,Tables, Views, Indexing and SQL syntax
Thanks to all of you and especially to Todd for your code of using LOCATE to look for nearest match results without using SEEK(avoid creating unnecessary index files). I have my code running well like this, might be able to share it with others.
fulllen=LEN(mScno)
FOR n = fulllen - 1 TO 1 STEP -1
SELECT mycursor
LOCATE ALL FOR LEFT(mycursor.scno,n)=LEFT(mScno,n)
IF FOUND()
thisform.refresh
thisform.lockscreen=.T.
thisform.Pageframe.pgList.setfocus
thisform.Pageframe.pgList.Grid.refresh
thisform.Pageframe.pgList.Grid.setfocus
thisform.lockscreen=.F.
EXIT
ENDIF
ENDFOR
Todd, I've done this for going to the begining of "B" if the users enter "D".
LOCATE ALL FOR LEFT(mycursor.scno,1)=LEFT(mScno,1)
IF !FOUND()
FOR n=1 TO ASC(LEFT(mScno,1)) STEP 1
LOCATE ALL FOR LEFT(mycursor.scno,1)=CHR(ASC(LEFT(mScno,1))-n)
IF FOUND()
thisform.refresh
thisform.lockscreen=.T.
thisform.Pageframe.pgList.setfocus
thisform.Pageframe.pgList.Grid.refresh
thisform.Pageframe.pgList.Grid.setfocus
thisform.lockscreen=.F.
EXIT
ENDIF
ENDFOR
ENDIF
THanks a lot.
Gan
>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 :-)
>
>
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only