home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / lib / tclX-6.4 / help / files / bsearch < prev    next >
Encoding:
Text File  |  1992-12-17  |  1.6 KB  |  28 lines

  1.  
  2.  
  3.           bsearch filehandle key [retvar] [compare_proc]
  4.                Search an opened file containing lines of text sorted
  5.                into ascending order for a match.  Filehandle is a Tcl
  6.                filehandle as returned by the open command.  Key
  7.                contains the string to match.  If retvar is specified,
  8.                then the line from the file is returned in retvar, and
  9.                the command returns 1 if key was found, and 0 if it
  10.                wasn't.  If retvar is not specified or is a null name,
  11.                then the command returns the line that was found, or an
  12.                empty string if key wasn't found.
  13.  
  14.                By default, the key is matched against the first
  15.                white-space separated field in each line.  The field is
  16.                treated as an ASCII string.  If compare_proc is
  17.                specified, then it defines the name of a Tcl procedure
  18.                to evaluate against each line read from the sorted file
  19.                during the execution of the bsearch command.
  20.                Compare_proc takes two arguments, the key and a line
  21.                extracted from the file.  The compare routine should
  22.                return a number less than zero if the key is less than
  23.                the line, zero if the key matches the line, or greater
  24.                than zero if the key is greater than the line.  The
  25.                file must be sorted in ascending order according to the
  26.                same criteria compare_proc uses to compare the key with
  27.                the line, or errouenous results will occur.
  28.