home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1996 July / macformat-039.iso / DATABASE / SHARED.DIR / 01044.ls < prev    next >
Encoding:
Text File  |  1996-03-14  |  734 b   |  31 lines

  1. on NameToNum name
  2.   set num to Bsearch(name, "MakerList")
  3.   return value(item 2 of line num of field "MakerList")
  4. end
  5.  
  6. on Bsearch str, txt
  7.   set txt to the number of cast txt
  8.   set start to 1
  9.   set end to the number of lines in field txt
  10.   set middle to (start + end) / 2
  11.   repeat while str <> item 1 of line middle of field txt
  12.     if str = item 1 of line end of field txt then
  13.       return end
  14.     end if
  15.     if start = middle then
  16.       return 0
  17.     end if
  18.     if str < item 1 of line middle of field txt then
  19.       set end to middle
  20.     else
  21.       set start to middle
  22.     end if
  23.     set middle to (start + end) / 2
  24.   end repeat
  25.   if str = item 1 of line middle of field txt then
  26.     return middle
  27.   else
  28.     return 0
  29.   end if
  30. end
  31.