How to filter a big list
Mark Wieder
mwieder at ahsoftware.net
Fri Oct 23 13:13:03 EDT 2009
Jérôme-
Friday, October 23, 2009, 8:51:18 AM, you wrote:
> If some body in the list is looking for a file with names and address
> (400K lines), I create a file with french name, French, Spanish,
> Italians, Portuguese first name and address of Geneva in Switzerland.
> It is possible to download here: http://files.me.com/jrosat/tac1b4
> In the state of my tests, here the my fastest code:
Since you seem to want to limit the display to 60 lines, here's a much
faster version. This takes roughly 90 milliseconds to do an entire
list, irrespective of the number of chars. Note as well that your text
file is actually delimited by commas rather than tabs.
-- time of the filtered list
on keyUp
local vListe
local tTime
put the milliseconds into tTime
put test1(vNoms) into vListe
put the milliseconds - tTime into field "fElapsedTime"
put vListe into field "fListe"
end keyUp
function test1 pNoms
local vListe
local x
set the itemdelimiter to comma
put empty into vListe
put 1 into x
repeat for each line theLine in pNoms
if item 2 of theLine contains me then
put theLine & cr after vListe
add 1 to x
if x > 60 then
put "..." & cr after vListe
exit repeat
end if
end if
end repeat
return vListe
end test1
--
-Mark Wieder
mwieder at ahsoftware.net
More information about the use-livecode
mailing list