Convergence using find?
Glen Bojsza
gbojsza at mac.com
Wed Apr 7 16:47:37 EDT 2004
Hi,
I was wondering if anyone has suggestions for converging to the nearest
number ( if the desired number doesn't exist) in a sorted field?
I have a field with 60,000 numbers sorted numerically and I have used
the find command in combination with a repeat loop to converge to the
nearest matching number.
One question I have does anyone know the find algorithm being used (is
it a Binary search where the field is constantly cut into half ...ie to
search for a number between 1 and 1,000,000 that is in a sorted field
this would take 7 loops to converge which is quite quick)
Currently I am trying...this works but is there another way?
on mouseUp
put 20 into x
repeat for the number of lines in fld "atest"
find x in fld "atest"
if the foundtext is empty then
put x + 1 into x
else
put the foundline
exit to top
end if
end repeat
end mouseUp
thanks,
Glen
More information about the use-livecode
mailing list