strange errors

I have my program running, but it doesn't seem to running correctly.

In my program, when I go and add a record, it adds it. But when I try to add
more records (one after another) it doesn't seem to go into the linked list.

Also, when I go to list what is in the linked list, I get garbage outputed.
if someone can help me fix these problems, that would be appreciated. below
is my ENTIRE program in a unit. errors occur in the procedures ADD, LIST (I
think, there might be other errors, if there are please tell me, and how to
correct them) Thanks.

Unit Database;
Interface

type
  Bookrec = RECORD
              Title:string[30];
     AuthorLastName: string[15];
    AuthorFirstName:string[15];
          Publisher:string[25];
               ISBN:string[13];
  end;

  booknode = ^bookptr;
  bookptr = record
    data: Bookrec;
    next: booknode;
  end;

{Compare functions}
function compare(bookrec1,bookrec2: Bookrec) : boolean;
function compare1(bookrec1,bookrec2: Bookrec) : boolean;
function compare2(bookrec1,bookrec2: Bookrec) : boolean;
{The functions compare, compare1, compare2 are used to compare certian
values to other values. IE: take current pointer and compare it with
input from user.}

{Search procedures}
procedure ISBNsearch(var bookrecord:Bookrec);
procedure AuthorSearch(var bookrecord:Bookrec);
{The proceudres ISBNsearch, and Authorsearch are used to get input from
user, then returns value back to previous position, then loads another
procedure to find record for user}

{Edit procedure}
procedure edit(var bookrecord:Bookrec);
{Gets user input to be stored into linked list}

{Show procedure}
procedure show(bookrecord:Bookrec);
{Displays all info in linked list}

{Find Position procedure}
procedure findPos(book: booknode; bookrecord: Bookrec;
                  var prev,foundAt: booknode);

procedure findPosauth(book: booknode; bookrecord: Bookrec;
                  var prev,foundAt: booknode);

procedure findPosisb(book: booknode; bookrecord: Bookrec;
                  var prev,foundAt: booknode);

{Finds position of the record by doing comparing of values. It is a general
  purpose procedure for adding,finding and deleting.
  finds the position of bookrecord if bookrecord is in list or
  position to insert if it doesn't exist.
  special cases:
  prev  = nil and foundAt =nil  => the list is empty;
  prev  = nil and foundAt<>nil => pos is in front of book;
  prev <> nil and foundAt =nil => pos is head end of book;
  to check if really foundAT^.data = bookrecord

Quote
}

procedure add(var book: booknode; bookrecord:Bookrec);
{Uses findpos procedure to correctly insert new record at correct position}

procedure del(var book: booknode; bookrecord:Bookrec);
{Used to delete records via ISBN code. Gets input from user and checks
to see if record is in linked list, if so deletes it, if not, returns
a error message}

procedure find(var book: booknode; bookrecord:Bookrec);
{Finds record for user by using author's last name, gets input from user
 and then goes to findpos procedure to find the record, once found, displays
 record on screen for user to see}

procedure disp(book: booknode);
{Displays all records in linked list.}

procedure readList(var book:booknode);
{Used to read a new file, and also get file input from user}

procedure writeList(book:booknode);
{Writes all contens to linked list when user wants to do it.}

Procedure menu;
{Presents the user a menu of choices so that the user can use certian
functions of the program. IE: add, delete, find, list, save.}

Implementation

uses CRT;

function compare;
begin{compare}
  compare := bookrec1.Title<bookrec2.Title{compares input to current
pointer}
end;{compare}

function compare1;
begin{compare1}
  compare1 :=bookrec1.AuthorLastName<bookrec2.AuthorLastName
end;{compare1}

function compare2;
begin{compare2}
  compare2 :=bookrec1.ISBN<bookrec2.ISBN
end;{compare2}

procedure ISBNsearch;
begin{ISBNserach}
  write('Delete book from inventory by ISBN code:  ');
  readln(bookrecord.isbn)           {Waits for user input, then returns
input
                                     to be processed in correct procedure/
                                     function}
end;{ISBNserach}

procedure AuthorSearch;
begin{AuthorSearch}
  write('Search for author''s book by last name:  ');
  readln(bookrecord.AuthorLastName)
end;{AuthorSearch}

procedure edit;
{Lets user input info into linked list/database}
begin{edit}
  write('Title:');
  readln(bookrecord.Title);
  write('Author''s Last Name : ');
  readln(bookrecord.AuthorLastName);
  write('Author''s First Name: ');
  readln(bookrecord.AuthorFirstName);
  write('Publisher:');
  readln(bookrecord.Publisher);
  write('ISBN:');
  readln(bookrecord.isbn)
end;{edit}

procedure show;
{Writes out info in linked list to screen}
begin{show}
  writeln('               Title: ',bookrecord.Title);
  writeln('  Author''s Last Name: ',bookrecord.AuthorLastName);
  writeln(' Author''s First name: ',bookrecord.AuthorFirstName);
  writeln('           Publisher: ',bookrecord.Publisher);
  writeln('                ISBN: ',bookrecord.isbn);
  writeln
end;{show}

procedure findPos;
{Finds position of record, for either adding, deleting, or finding}
var done : boolean;
begin{findpos}
  prev := nil;                          {sets Previous pointer to NIL}
  done := book = nil;
  while not done do                     {makes sure that var done is not
nil}
  begin
    done := not compare(book^.data,bookrecord);        {goto function
compare}
    if not done then                    {If the var is not nil then}
    begin
      prev := book;                        {sets previous to}
      book:=book^.next;                    {sets pointer to next}
      done := book=nil                     {sets done and the pointer to
nil}
    end
  end;
  foundAt := book                          {sets found item to current
pointer
                                            position}
end; {findpos}

procedure findPosauth;
{Finds position of record, for either adding, deleting, or finding}
var done : boolean;
begin{findpos}
  prev := nil;                          {sets Previous pointer to NIL}
  done := book = nil;
  while not done do                     {makes sure that var done is not
nil}
  begin
    done := not compare1(book^.data,bookrecord);        {goto function
compare}
    if not done then                    {If the var is not nil then}
    begin
      prev := book;                        {sets previous to}
      book:=book^.next;                    {sets pointer to next}
      done := book=nil                     {sets done and the pointer to
nil}
    end
  end;
  foundAt := book                          {sets found item to current
pointer
                                            position}
end; {findpos}

procedure findPosisb;
{Finds position of record, for either adding, deleting, or finding}
var done : boolean;
begin{findpos}
  prev := nil;                          {sets Previous pointer to NIL}
  done := book = nil;
  while not done do                     {makes sure that var done is not
nil}
  begin
    done := not compare2(book^.data,bookrecord);        {goto function
compare}
    if not done then                    {If the var is not nil then}
    begin
      prev := book;                        {sets previous to}
      book:=book^.next;                    {sets pointer to next}
      done := book=nil                     {sets done and the pointer to
nil}
    end
  end;
  foundAt := book                          {sets found item to current
pointer
                                            position}
end; {findpos}

function Emptylist(book:booknode):boolean;
begin
emptylist:=(book=nil)
end;

procedure add;
var
  current,prev,list: booknode;
  empty:boolean;
  begin{add}
{  book:=nil;}
  new(current);                               {creates a new node at current
                                               position}
  current^.data := bookrecord;                 {sets current pointer to be
able
                                               to store record in memory
slot}
  findpos(book,current^.data,prev,book);          {calls findpos procedure
to
                                                locate the end of the linked
                                                list}
  if prev=nil then                   { list empty or
current^.data<book^.data }
  begin
    current^.next := book;
    book := current
  end
  else
  begin
    prev^.next := current;
    current^.next := book
  end
end;

procedure del;
var
  prev, head: booknode;
  found : boolean;
begin
  findposisb(book,bookrecord,prev,head);
  if head = nil then                   {cheks if current pointer is NIL if
so}
    begin
    clrscr;
    gotoxy(10,9);
    writeln('Entry not in inventory');{returns error msg, if not continues
with}
    gotoxy(10,10);
    writeln('Press ENTER to continue');
    readln
    end
  else                               {Procedure}
    if compare2(bookrecord,head^.data) then            {cheks if entry is in
list if so}
     begin
      gotoxy(10,9);
      writeln('Entry is not in inventory'); {continues on and deletes
record}
      gotoxy(10,10);
      writeln('Press ENTER to continue');
      readln
     end
    else                                   {if not returns error msg}
    begin
      if prev = nil then            {bookrecord is the first element in
book }
      begin
        prev := book;                   {sets previous node to the current}
        book:=book^.next;               {sets current to the next node}
        dispose(prev)                   {deletes the previous node/record}
      end
      else
      begin
        prev^.next := head^.next;         {sets previous node to the current
                                         node}
        dispose(head)                     {deletes the current node pointer
is
                                         pointing to}
      end;
      begin
      gotoxy(10,9);
      writeln('Entry deleted.');
      gotoxy(10,10);
      writeln('Press ENTER to continue');
      readln
      end;
    end
end; {del}

procedure find;
var
  prev, head: booknode;
  found : boolean;
begin
  findposauth(book,bookrecord,prev,head); {gotos procedure FINDPOS to locate
                                         position of record}
  if head = nil then                      {if procedure returns a nil
pointer
                                         then an error msg is displayed}
    writeln('- Not in list')
  else
    if compare1(bookrecord,head^.data) then {But is procedure FINDPOS
returns
                                          any code expect nil, then the
                                          input is compared with the records
                                          to locate actual positon of
record,
                                          if record doesn't exist, then
error
                                          msg is displayed}
     begin
     clrscr;
      writeln('- Not in list');
      write('Press ENTER to continue');
      readln;
      exit
     end
    else
     begin                      {section to see if record exists, if so then
                                 record is displayed on screen}
      writeln('Record found');
      writeln('displaying all book(s) written by
',bookrecord.AuthorLastName);
      show(book^.data)
     end;
  begin
  write('Press ENTER to continue');
  readln
  end
end; {find}

procedure disp;
{Displays all entries in linked list}
var
  counter: integer;
  list:booknode;
begin{disp}
  clrscr;
  title;                                {calls procedure to print
                                         header to screen}
  counter:=0;                           {sets (page) counter to 0}
  while book<>nil do
  if counter=4 then                     {if counter equals 4 (number of
                                         records displayed on screen
                                         resets counter and displays 4
                                         more records, until pointer=nil}
  begin
  counter:=0;
  write('Press ENTER to continue');
  readln;
  clrscr
  end
  else
  begin
    book:=list;
    show(book^.data);
    inc(counter);
    book := book^.next;
  end;
 write('Please press ENTER to continue');
 readln
end; {disp}

procedure readList;
var
  infile : file of Bookrec;
  filename : string;
  bookrecord : Bookrec;
  response:char;
  errorcode:integer;
begin{readlist}
  write('Enter name of file to open(FILENAME.DAT):  ');
  readln(filename);
  if filename='' then exit;{If user doesn't input a file name, then
                            exits procedure}
  assign(infile,filename);  {gives file the name of the var}
  {$I-}                     {turns off error cheking for file}
  reset(infile);            {opens file to be read}
  errorcode:=IORESULT;      {sets errorcode to the input/output result}
  {$I+}                     {turns file error cheking on}
                  if errorcode=2 then
                     begin
                       clrscr;
                       writeln('File ',filename,' does not exist');
                       write('Would you like to make it?');
                       readln(response);
                          if (response='Y') or (response='y') then
                               rewrite(infile) {creates a new file}
                          else
                           begin
                            exit
                           end
                     end
                  else

  while not eof(infile) do
  begin
    read(infile,bookrecord);{reads file record by record}
    if ioresult<>0 then exit;
    add(book,bookrecord);   {inserts all records into linked list}
  end;
 close(infile)
end; {readlist}

procedure writeList;
var
  infile : file of Bookrec;
  filename : string;
  bookrecord : Bookrec;
begin{writelist}
  gotoxy(19,16);
  write('File to save to (FILENAME.DAT):');
  readln(filename);
  if filename='' then exit;
  assign(infile,filename);
  reset(infile);
  if ioresult <> 0 then exit;
  while book<>nil do
  begin
    write(infile,book^.data);
    if ioresult<>0 then exit;
    book:=book^.next
  end;
  close(infile)
end; {writelist}

Procedure create(var list:booknode);
var
data:booknode;

begin
list:=nil;
data:=nil
end;

Procedure menu;
var
  list: booknode;
  bookrecord: Bookrec;
  response:char;
  question:char;
  book:booknode;

begin{menu}
   clrscr;
  create(list);
  readlist(list);
  repeat
  clrscr;
    writeln;
    gotoxy(19,3);
    writeln('Menu :');
    gotoxy(19,5);
    writeln(' A: Add a new book to inventory');
    gotoxy(23,6);
    writeln('(entry is sorted by title)');
    gotoxy(19,8);
    writeln(' D: Delete a book from inventory');
    gotoxy(23,9);
    writeln('(delete via ISBN)');
    gotoxy(19,11);
    writeln(' F: Find and display all book');
    gotoxy(23,12);
    writeln('by specified author (via last name)');
    gotoxy(19,14);
    writeln(' L: Display entire inventory (sorted by title)');
    gotoxy(19,16);
    writeln(' W: Write list (to new file or exisiting file)');
    gotoxy(19,18);
    writeln(' Q: Quit');
    gotoxy(19,22);
    write('Please enter choose [A..Q]:  ');
    readln(response);

    case response of
     'A','a' :
       begin
         clrscr;
         writeln('Add:');
           repeat
           edit(bookrecord);
           add(list,bookrecord);
           write('Add another book? (y/n)');
           readln(response);
           until (response='N') or (response='n')
       end;
     'D','d' :
       begin
         clrscr;
         writeln('Delete:');
         ISBNsearch(bookrecord);{calls ISBNsearch procedure to find
                                 specific book}
         del(list,bookrecord)   {once found, deletes book (node)from linked
                                list}
       end;
     'F','f' :
       begin
         clrscr;
         writeln('Find:');
         AuthorSearch(bookrecord); {calls authorsearch procedure to locate
                                    author}
         find(list,bookrecord)     {then takes input and locates record in
                                    linked list}
       end;
     'L','l' :
             begin
             clrscr;
{             book:=nil;}
             disp(list)             {displays all entries in linked list}
             end;
     'W','w' :
             begin
             clrscr;
             writeList(list)
             end
    end;
  until (response='Q') or (response='q');               {repeats section
                                                        until input equals
                                                        desired response}
  clrscr;
  gotoxy(19,15);
  write('Do you want to save the current database? (Y/N)'); {Gives user to
                                                             save file under
                                                             current
filename
                                                             or new
filename}
  readln(question);
  if (question ='Y') or (question='y') then
  writelist(list)                                           {Calls procedure
                                                            writelist to
save
                                                            file under
filename}
  else
 end;

end.{menu}