Information générale
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
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 :-)
>
>
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement