sorry i hope this is better...
record decleartion and file variables:
implementation
uses Unit1, Unit3;
Type
HighScores = record
Name: String[15];
Score: Integer;
end;
Var HighScore: array[1..10] of HighScores;
ScoresFile: file of HighScores;
HighScoresdata: HighScores;
other highscores code:
AssignFile(ScoresFile, 'Scores.dat'); {assigns the variable 'Scores File' to the file 'Scores.dat' on the HDD}
reset(ScoresFile); {resets the file pointer to the begining of the file}
while not eof(ScoresFile) do
begin
read(ScoresFile, HighScoresData); {reads all of the data on the file to the highscores record}
end; {while}
if Score > HighScore[10].Score then {if player's score is greater than the 10th highscore than the player's score becomes the 10th highscore}
begin
HighScore[10].Score:=Score;
HighScore[10].Name:=InputBox('HighScores', 'Congradulations you got a high score!', 'Enter your name here'); {player's name is entered into the record}
HighScoresCont := true; {condition to start the sorting process is set to true}
Inputname:=True; {condition to allow option to view highscores}
end; {if}
while HighScoresCont do {while the highscorescont is true the program will sort the highscores from highest to lowest}
begin
HighScoresCont := false;
for HSSort:= 1 to 10 do
if HighScore[HSSort].Score < HighScore[HSSort+1].Score
then begin
HSTemp := HighScore[HSSort].Score;
HighScore[HSSort].Score := HighScore[HSSort+1].Score;
HighScore[HSSort+1].Score := HSTemp;
HighScoresCont := true;
end; {if}
end; {while}
Reset(ScoresFile); {resets the file pointer to the begining of the file}
write(ScoresFile, HighScoresData); {the highscores record is written to disk} {this line is highlighted in blue when the error message occurs}
CloseFile(ScoresFile); {closes 'ScoresFile', saving any new information}
if InputName = True then {if name has been entered then option to view highscores is given to the player}
begin
ViewHS := MessageDLg('Do you want to view highscores?', mtConfirmation, [mbYes, mbNo], 0) = mrYes;
if ViewHS then
begin
FrmHighScores.show;
FrmMainGame.Visible:=False;
end;
end;
end;
end;