Two Questions About My Search Field

Andre.Bisseret Andre.Bisseret at inria.fr
Tue Jan 13 11:36:14 EST 2009


Le 12 janv. 09 à 23:41, Gregory Lypny a écrit :

> 	Hello everyone,
>
> 	I've created a search field that takes a phrase typed into it and  
> searches a data field for lines containing the phrase.  It works in  
> the usual way where the search becomes narrower the more you type.   
> What I haven't been able to do is go backwards, that is, make the  
> search wider as characters are deleted from the end of the search  
> string when the delete key is hit.  When the delete key is hit,  
> nothing happens, and I'm not sure how to work a delete key message  
> into the handler.
>
> on keyDown pKey
>   put me & pKey into searchString
>   get fld "Data"
>   repeat for each line thisLine in it
>      if searchString is among the words of thisLine
>      then
>         put thisLine & return after hits--Whole words
>         next repeat
>      else
>         if thisLine contains searchString then put thisLine & return  
> after otherHits
>      end if
>   end repeat
>   put otherHits after hits
>   if the last character of hits is return then delete the last  
> character of hits
>   put hits into fld "Browse List"
>   put 1*the number of lines in hits && "records" into fld "Number of  
> Records"
>   pass keyDown
> end keyDown
>
Hello,
Af for your first question, In several stacks I have a field  
"entrée" (your "search field"), a field "dataFld" and a field  
"résultats"
in the script of the field "Entrée" I have the following handler that  
works including badkwards

ON rawkeyUp which
local maSousListe,
----------
      IF which is 65293 THEN pass rawkeyUp ---just because I need a  
returninField handler
     REPEAT
       find fld "entrée" in fld "dataFld"
       IF the result is "not found" THEN exit repeat
       put value(the foundline) & cr after maSousListe
     END repeat
     put empty into fld "résultats"
     put maSousListe into fld "résultats"
     select  line 1 of fld "résultats"
     select after fld "entrée"
     put empty into maSousListe
END rawkeyUp

HTH
Best regards from Grenoble

André





More information about the Use-livecode mailing list