I am reading a text file into a record array. Part of the data in the text files are program grades and test grades. Can I declare an array of integers to fold the program or test values as a field in the record? If so, then how do I access the individual program values in the field?
For example, could I declare the record like this? And if so how would I input or access data from say test[3]?
nametype = record
first : string[10];
mi : string[3];
last : string[30];
end;
stype = record
id : integer;
name : nametype;
prog : array[1..10] of integer;
test : array[1..3] of integer;
progave, quizave : real;
average : double;
grade : char;
end;
sarraytype = array[1..100] of stype;
var
student : sarraytype;
So I guess where I’m stuck is reading into these arrays. So far for my read I have:
procedure TstudentData.openButtonClick(Sender: TObject);
begin
var i : integer;
if open.execute then
begin
assignfile(inf,open.FileName);
reset(inf);
i := 1;
while not eof(inf) do with student[i] do
begin
readln(inf, id, name.first, name.mi, name.last);
i := i + 1;
end;
end;
i:=1;
end;
I have the read for the other data, but I’m at a total loss for how to read into the prog and test arrays.
You can. By an example …
as response to your comment
BTW:
Usual naming would be