I need to o an assignment where i make two programs, one to write a list of players in a team and their scores, the other to read and search the .dat file for specific players. i have chosen to do this with an array but when i run my 1st program after i enter my first players score i get an exitcode 201. Im not sure what to do and im running out of time.
My Code

Program TeamWrite;
Var FName : String;
        UserFile : Text;
        Players : array[1..10] of string;
        Score : array[1..10] of integer;
        List1: Integer;
        List2: Integer;

BEGIN
      FName := 'Team';
        Assign(UserFile, 'C:\Team.dat');
        Rewrite(UserFile);
        FOR List1:= 1 to 10 DO
                begin
                    Writeln('Enter players name and score separated by pressing enter.');
                    Readln(Players[List1]);
                    Readln(Score[List2]);
                    Writeln(UserFile, Players[List1]);
                    Writeln(UserFile, Score[List2]);
                end;
        close(UserFile);
End.

Think what the value of List2 is in this line:

Writeln(UserFile, Score[List2]);

or here:

Writeln(UserFile, Score[List2]);

You don't initialize List2 to any known value and you never change it.

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.