I cannot read the info I stored into the files and I need help. Whenever I give the user the option of saving more records or simply retrieving a record, it always stops on the retrieving part.

Type
    Str25    = String[25];
    TBookRec = Record
                Title, Author,
                ISBN  : Str25;
                Price : Real;
               End;

Procedure EnterNewBook(var newBook : TBookRec);
Begin
 Writeln('Please enter the book details: ');
 Write('Book Name: ');
 Readln(newBook.Title);
 Write('Author: ');
 Readln(newBook.Author);
 Write('ISBN: ');
 Readln(newBook.ISBN);
 Write('Price: ');
 Readln(newBook.Price);
End;

Var
    bookRecArray : Array[1..10] of TBookRec;
    tempBookRec  : TBookRec;
    bookRecFile  : File of TBookRec;
    i            : 1..10;
    choice: integer;

Begin

writeln('Press 1 to record more books, Press 2 to looks at records');
readln(choice);
if choice=1 then
 begin
 Assign(bookRecFile, 'bookrec.dat');
 ReWrite(bookRecFile);
 For i := 1 to 10 do
  Begin
   EnterNewBook(bookRecArray[i]);
   { bookRecArray[i] now contains the book details }
   Write(bookRecFile, bookRecArray[i]);
  End;
 Close(bookRecFile);
 Writeln('Thanks for entering the book details.');
 Writeln('They are saved in a file!');
 end;

 if choice=2 then
  begin
 Write('Now choose a record to display from 1 to 10: ');
 Readln(i);
 ReSet(bookRecFile);
 Seek(bookRecFile, i-1);
 Read(bookRecFile, tempBookRec);
 Close(bookRecFile);
 Writeln('Here are the book details of record #',i,':');
 Writeln;
 Writeln('Title:  ', tempBookRec.Title);
 Writeln('Author: ', tempBookRec.Author);
 Writeln('ISBN:   ', tempBookRec.ISBN);
 Writeln('Price:  ', tempBookRec.Price);
 end;
 Readln;
End.

You Assign the file only if choice=1, so choice=2 crashes. It should be more obvious how many books must enter and which number is now.
No need to limit program to ten books. Better to search by title than ask number of book.

Program should repeat until user wants to quit. If there are few books only, good main menu includes list of all books or books fulfilling current search criteria, possibly paged, and prompt.

You Assign the file only if choice=1, so choice=2 crashes. It should be more obvious how many books must enter and which number is now.
No need to limit program to ten books. Better to search by title than ask number of book.

Program should repeat until user wants to quit. If there are few books only, good main menu includes list of all books or books fulfilling current search criteria, possibly paged, and prompt.

Alright thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.