Two Questions About My Search Field
Andre.Bisseret at inria.fr
Tue Jan 13 10:36:14 CST 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
> put thisLine & return after hits--Whole words
> next repeat
> 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
> pass keyDown
> end keyDown
Af for your first question, In several stacks I have a field
"entrée" (your "search field"), a field "dataFld" and a field
in the script of the field "Entrée" I have the following handler that
works including badkwards
ON rawkeyUp which
IF which is 65293 THEN pass rawkeyUp ---just because I need a
find fld "entrée" in fld "dataFld"
IF the result is "not found" THEN exit repeat
put value(the foundline) & cr after maSousListe
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
Best regards from Grenoble
More information about the use-livecode