Finding

Geoff Canyon gcanyon at inspiredlogic.com
Sun Jan 6 01:21:01 EST 2002


At 8:58 PM -0800 1/5/02, Scott Rossi wrote:
>As a small test of my own, I made a field, filled it with 5000 lines of
>random numbers, and ran the routine I suggested to find all occurrences of
>the number 10.  On a 450mHz Mac, MC returns the result in 1.016 seconds.
>Doesn't seem too slow to me...

Whenever repeating your way through data, the repeat for each form is generally much faster. This, for example, will execute in about 3 ticks (.05 seconds) on a field with 5000 lines of numbers from 1 to 20 on my 400mHz Mac:

on mouseUp
  put 10 into N
  put fld "testField" into tData
  put empty into tSummary
  put 1 into x
  repeat for each line L in tData
    if L = N then put x & "," after tSummary
    add 1 to x
  end repeat
  delete last char of tSummary
end mouseUp

Bill Vlahos is right about the filter command. I modified the routine that generated the random numbers for the above test to put the line number after the  random number, so the data looked like this:

20 1
8 2
15 3
4 4
3 5
10 6
5 7
19 8
1 9
6 10
2 11

This allows using the Filter command: copy the data, filter the data, then pick up the line number (or whatever else) out of the filter results. The following script executes in 6 ticks, but not on 5000 lines of data, but 50,000!!

on mouseUp
  put fld "testField" into tData
  filter tData with "10*"
end mouseUp

regards,

Geoff



More information about the use-livecode mailing list