filterWSearch

April 29, 2008 in Linux, Mac OS X, Vista, Windows XP by chip

First, the search field script:

ON keyUp tKey
FilterWSearch me
END keyUp

ON backspaceKey
delete char -1 of me
FilterWSearch me
END backspaceKey

Obviously we’re not accounting for arrows, selected text, but it works fine, no one misses those things, for a simple search people just type a few characters…)

Then, the table field (“theData”) contains the records, and also, a custom property (“uData”) with the data.

Then, somewhere in the message path:

ON FilterWSearch pSearch
lock screen
put the uData of fld "theData" into tList


IF pSearch is not empty THEN
filter tList WITH "*" & pSearch & "*"
END IF


put tList into fld "theData"
END FilterWSearch

This way, if there is nothing in the search box, the table field shows all records, otherwise, it shows only records with a string matching the string typed into the search box.