Difficulty displaying all records included in a file

I am trying to make a procedure to display all of the records in a file, at the moment it only displays the last record entered into the file.

How can i get this to work?

Here is my code; sorry if it is a bit messy!

[code]
PROCEDURE DisplayAll;
BEGIN
IF FILESIZE(quotefile) = 0 THEN
BEGIN
WRITELN('Opening file...');
WRITELN;
TEXTCOLOR(4);
WRITELN('Error - File is empty');
TEXTCOLOR(10);
WRITELN;
END
ELSE
BEGIN
RESET(quotefile);
While not eof(quotefile) do
READ(Quotefile, quotes);
WITH QUOTES DO
BEGIN
TEXTCOLOR(10);
WRITELN('Name: ');
textcolor(4);
WRITELN(Title + ' '+ FirstName+' ' + LastName);
writeln;
textcolor(10);
WRIteLN('Address: ');
textcolor(4);
write(HouseNumber);
WRITEln(' '+ StreEtName);
WRITELN(cITY);
WRITELN(POSTCODE);
TEXTCOLOR(10);
WRITELN;
WRITELN('Contact details:');
TEXTCOLOR(4);
WRITELN(MOBILE);
WRITELN(eMAIL);
TEXTCOLOR(10);
WRITELN;
WRITELN('Quote details:');
textcolor(10);
write('Registration Number: ');
TEXTCOLOR(4);
WRITELN(rEGISTRATION);
textcolor(10) ;
write('Amount to be borrowed: ');
textcolor(4) ;
WRITELN(Price:5:2);
TEXTCOLOR(10);
WRITE('Years to be borrowed for: ');
TEXTCOLOR(4);
WRITELN(Quotes.YearsBorrowed);
textcolor(10);
write('Deposit to be paid: ');
TEXTCOLOR(4);
WRITELN(Quotes.Deposit:5:2);
textcolor(10);
write('Total interest to be paid: ');
TEXTCOLOR(4);
WRITELN(Quotes.totalinterest:5:2);
textcolor(10);
write('Installment to be paid per month: ');
TEXTCOLOR(4);
WRITELN(Quotes.PayPerMonth:5:2);
textcolor(10);
WRITE('Total to be paid: ');
textcolor(4);
WRITELN(Quotes.totaltopay + quotes.deposit:5:2);
WRITeLN;
textcolor(10);
END;
END;
WRITELN('Press enter to return to the main menu.');
READLN;
WRITE (Quotefile, Quotes);

END;
[/code]

Thank you so much for your interest!

P.S. i need an answer to this soonish, i am going to continue working on the rest of the program and return to this later, thanks again.

Could i also add...

I get error 26: type mismatch for this line:
[code]
FILESEEK(quotefile,FILEPOS(quotefile)-1);
[/code]

Thanks again =]

Comments

  • You need a BEGIN-END block for the WHILE loop - right now the WHILE look just does READ's till end of file.

    Trev
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion