LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!
the filter function seems very straightforward - yet I can't get it to work for me...
I'm using a text entry field to specify a filter word, that should then be used to filter the lines of a table field containing words in column 1, and numbers in column 2.
filter tSource with tSearch into tResult --- where tSource would be the full table, tSearch a searchstring, and tResult the desired subset of tSource, showing only lines matching tSearch.
Apparently I can't use the filter function on a table field directly, so I need to add some processing steps in between - but which?
Convert the table back into a string with certain delimiters > filter > convert it back into table format...?? Is there a simple & elegant way to do this?
Running my script variants just end up purging the content instead of filtering it.
Hi Maurice,
I'd put the full table info into a custom property with an item delimiter (could be cr). Then when doing the search put the custom property into a variable, do the filter and replace the table with what is left.
The full table will always be available via the custom property.
You probably have seen empty cp's as they are in every control.
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
on mouseUp
set the itemdel to cr
put the text of fld "searchFrequency" into tSearch
put the text of fld "WordFreq" into tSource
filter items of tSource with tSearch into tResult
put tResult into fld "wordFreq"
end mouseUp
The original field (Simon, totally agree about using a cProp for persistance in later use) "wordFreq" that I want to overwrite - here it just gets purged, as before.
The field should just be repopulated / overwritten with what's in tResult var, no?? What am I missing...
Do filters have to come in a Regex flavor? Sorry, three guys helping - but still not getting it.
on mouseUp
set the itemdel to cr
put the text of fld "searchFrequency" into tSearch
put the text of fld "WordFreq" into tSource
filter items of tSource with tSearch into tResult
put tResult into fld "wordFreq"
end mouseUp