home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / mailpro / findfile.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1988-08-23  |  683 b   |  32 lines

  1. unit FindFile;
  2.  
  3. interface
  4. uses Def, RE, UCasU;
  5. function FindInFile(var FindName: string): longint;
  6.      (* essentially a binary search *)
  7.  
  8. implementation
  9.  
  10. function FindInFile;
  11. var First,
  12.     Last,
  13.     Middle,
  14.     Lngth:               longint;
  15.     TestName:            string;
  16. begin
  17. First := 0;
  18. Last := SortTop;
  19. Lngth := length(FindName);
  20. while (First + 1) < Last do
  21.     begin
  22.     Middle := (First + Last) div 2;
  23.     GetRec(Entry,Middle);
  24.     TestName := UCase(copy(Entry.Addressee,1,Lngth));
  25.     if FindName > TestName then First := Middle else Last := Middle;
  26.     end;         (* end while *)
  27. (* FirstDisplay:=Last; *)
  28. FindInFile := Last;
  29. end;
  30.  
  31. end.
  32.