Forward and Reverse filtering a List field

Mike Bonner bonnmike at gmail.com
Fri Jun 18 19:40:51 EDT 2010


Well the reason it lags by 1 char is because it does the compare on
keydown. The letter doesn't actually show in the field till the key is
up. You could switch your handler to rawkeyup instead to solve that
portion easily.  As for speed, there are surely ways that can optimize
the script such as how you apply your filters.  IE if you have 4
filters as you suggest, only 1 field will be typed into at a time,
which means that you can pre-filter with the 3 off fields first and
use THAT data with each keypress in the current field.  So the first
keypress in the field would filter based on all 4 filter fields, all
subsequent would do a single filter.

However, I tried my sample stack with 100k lines and it was acceptably
fast.  I'll send the attachment directly to my sample stack as cc
directly to you.

Also, was wondering if a datagrid might be better for this than a
table, but the table field works well enough if thats all you need.


On Fri, Jun 18, 2010 at 5:27 PM, Mark Stuart <mfstuart at cox.net> wrote:
>
> Hi Mike,
> First thanks for replying.
> How do I see/dl your attachment. I'm using the Browser to view the list, and
> therefore don't see any option for dl.
> Unless of course you also replied to my personal email, which I haven't
> received yet.
>
> Here's what I have so far...
>
> Stack objects:
> button: Load Accounts
> fld: Filter
> fld: List
>
> Load Button script:
> --===
> global dbConnID, gList
>
> on mouseUp
>   put revOpenDatabase("odbc","adaptSAMPLE",,,,) into dbConnID
>
>   if dbConnID is not a number then
>      answer error "DB Connection error:" && dbConnID
>      exit to top
>   end if
>
>   put "SELECT Account_Number,Account_Name,Account_Manager FROM account
> ORDER BY Account_Name" into tSQL
>
>   put revDataFromQuery(,,dbConnID,tSQL) into fld "List"
>   set the itemDel to tab
>   sort lines of fld "List" by item 1 of each
>   put fld "List" into gList  --put the returned data into a global for use
> in the filter
> end mouseUp
> --===
>
>
> fld List script:
> --===
> global gList
> local tList
>
> on rawKeyDown
>   put gList into tList
>   put the text of me into tText
>   filter tList with tText & "*"
>   put tList into fld "List"
>   pass rawKeyDown
> end rawKeyDown
> --===
>
> For each key stroke the script gets the original data and puts it into the
> local tList var.
> So it filters on the original data set for each key stroke. This could be
> slow.
>
> The Filter fld script seems to work, but the behavior is a little strange.
> When typing in the first character (for a starting value in the list I know
> is there), it does nothing - it does not filter.
> When I type the second character, it is like it is the first character typed
> in. It seems it's one character behind in applying the filter.
>
> What's up with that? Is my script anywhere near to work correctly and
> efficiently?
>
> Regards,
> Mark Stuart
> --
> View this message in context: http://runtime-revolution.278305.n4.nabble.com/Forward-and-Reverse-filtering-a-List-field-tp2260720p2260846.html
> Sent from the Revolution - User mailing list archive at Nabble.com.
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>


More information about the use-livecode mailing list