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.