title: Searching a file of records in Delphi data file
body: <p>Im creating a program that displays a list of 10 books with the title, author and ISBN. The program can display the records and sort them but I am having trouble to searching for him. I do not know where to implement the FindArray identifier into the code and I don't know how to get the program to search for the Book. The records are stored in a .dat file. Any help would be appreciated. Here's the code:</p>
  
  <pre><code> uses SysUtils;
  
   type TBook = Record
  
             Number : integer;
             Title : String[50];
             Author : String[50];
             ISBN : String[13];
           end;
  
   var Book : TBook;
  
  
  CurrentFile : File Of TBook;
  
  index : integer;
  FindArray : array[1..10] of TBook;
  
  Procedure Add_Book;
  
  var Title, Author, ISBN : String;
  index : integer;
  
  begin
   Assign (CurrentFile, 'C:\Books.dat');
   reset (CurrentFile);
   Seek (CurrentFile, filesize(CurrentFile));
   Book.Number := (filepos(CurrentFile)+1);
   writeln ('Type in book title');
   readln (Title);
   For index := 1 to Length(Title) do
   Title[index] := Upcase(Title[index]);
   Book.Title := Title;
   writeln ('Type in author');
   readln (Author);
   For index := 1 to Length(Author) do
   Author[index] := Upcase(Author[index]);
   Book.Author := Author;
   writeln ('Type in ISBN');
   readln (ISBN);
   For index := 1 to Length(ISBN) do
   ISBN[index] := Upcase(ISBN[index]);
   Book.ISBN := ISBN;
   write (CurrentFile, Book);
   Close (CurrentFile);
   end;
  
   Procedure Show_All;
   begin
     Assign (CurrentFile, 'C:\Books.dat');
     reset (CurrentFile);
     while filepos(CurrentFile) &lt;&gt; filesize(CurrentFile) do
     begin
       read (CurrentFile, Book);
       writeln ('File: ', Book.Number);
       writeln ('Title: ', Book.Title);
       writeln ('Author: ', Book.Author);
       writeln ('ISBN: ', Book.ISBN);
       writeln;
    end;
   writeln;
   write ('END OF FILE!');
   readln;
   Close (CurrentFile);
   end;
  
  Procedure Delete_All;
  begin
    Assign (CurrentFile, 'C:\Books.dat');
    reset (CurrentFile);
    seek (CurrentFile,0);
    Truncate (CurrentFile);
    Close (CurrentFile);
  end;
  
  Procedure Menu;
  
  var option :integer;
  
  begin
    writeln ('Press appropriate number');
    writeln;
    writeln ('1. Search book');
    writeln ('2. Quit');
    readln (option);
    CASE option of
     1: show_all;
     2: delete_all
     else;menu
     end; {End Case}
  end;
  
  begin
    Assign (CurrentFile, 'C:\Books.dat');
    reset (CurrentFile);
    index := 0;
    while not eof(CurrentFile) do
    begin
      index := index+1;
      read (CurrentFile, Book);
    end;
    index := Book.Number;
    repeat
    menu
     until eof(CurrentFile);
     close (CurrentFile)
    end.
  </code></pre>
  
  <p>This is my code so far. What do I have to do to make it search for the book title or the author?</p>