How to filter a big list

DunbarX at aol.com DunbarX at aol.com
Fri Oct 23 10:03:41 EDT 2009


Yesterday I went back to an old HC stack that filtered just such a list. I 
tried a Rev version of it on a list of 400,000 lines and it seems to run 
reasonably responsively. If this has already been dealt with better, then just 
ignore...

There is a search field and another field named "results". I put the list 
in a global called "clientlist", so one could just go and type into the 
search field at any time. In the search field script:

on rawkeyUp tkey    
    if length(line 1 of me) < 4 then pass rawkeyUp
    put line 1 of me into tofind   --lose errant returns
    get revFullFind(clientList,toFind,"lineNum","false")
    repeat with y = 1 to number(lines of it)
       put line line y of it of clientlist & return after temp1
    end repeat
    if temp1 = "" then put "No such" && quote & tofind & quote && "found" 
into fld "results"
    else put temp1 into fld "results"
end rawkeyUp

function revFullFind theText,toFind,form,exactly
    
    repeat for each line theline in thetext
       add 1 to counter
       if exactly = "true" then
          if toFind = theLine then
             if form = "lineNum" then x
                put counter & return after temp22
             else   if form = "txt" then
                put theLine & return after temp22
             end if
          end if
       else
          if toFind is in theLine then
             if form = "lineNum" then
                put counter & return after temp22
             else   if form = "txt" then
                put theLine & return after temp22
             end if
          end if
       end if
    end repeat
    
    return temp22
end revFullFind

"revFullFind" was one of my earliest Rev efforts; it duplicates much of 
Rinaldi's "fullFind". It gives here a return delimited list of line numbers of 
all occurrances of a string found in another string, which is then mapped to 
the riginal data.

Craig Newman



More information about the use-livecode mailing list