Using Borland Pascal- Making a program to read in names and sales figures from text file and then (amongst other things) find the average of the sales and compare all the sales figures to the average. The problem is, only the last entry in the text file comes out for the average comparison. All other aspects of the program work fine. I believe the problem is in this procedure (the rest of the program can be provided on request, it's kinda long):

Procedure comparison;
begin
For index:= 1 to max do;
begin
compare:=sales[index]-average;
Write (names[index],' ');
If compare>0 then
begin
textcolor (green);
Writeln ('£',compare:4:2);
end
else
begin
textcolor (red);
Writeln ('£',compare:4:2);
end;
readkey;
end;
textcolor (white);
end;

Hi, I dont see the problem here.
I would suggest check the followin:
Is max set to the size of sales ?
Does sales contain more the 1 entry ?
What does the readkey procedure do ?
(I code in Dephi so i have to get accustomed to pascal syntax).

Hi,

Simply remove the ; on the line For index:= 1 to max do;

Loren Soth

Be a part of the DaniWeb community

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