Hi,
For a homework assignement, I'v been asked to write a small school administration system.
Currently, the user is able to enter a new student and their age which is then stored in a text file.
This all works fine but now I need to load the contents of the text file into an array where the data can then be represented and used.
The code is written below
program school2;
USES CRT,SYSUTILS;
procedure loaddata;
Begin
End;
procedure enterstudent;
VAR
name:string;
age:integer;
currentfile:text;
Begin
CLRSCR;
writeln('Student Name: ');
readln(name);
writeln('Student Age: ');
readln(age);
Assign(currentfile, 'C:\Users\lavinia\documents\studentdatabase\studentdatabase.txt');
Append(currentfile);
writeln(currentfile, name, ',', age);
Close(currentfile);
End;
procedure setup;
VAR
choice:char;
currentfile:text;
Begin
CLRSCR;
writeln('Welcome to setup....');
writeln('Would you like to setup/restart a new student database (y/n)');
readln(choice);
if choice = 'y'
then begin
Assign(currentfile,'C:\Users\lavinia\Documents\studentdatabase\studentdatabase.txt');
rewrite(currentfile);
close(currentfile);
end
else begin
end;
End;
procedure mainmenu;
VAR
choice:char;
Begin
repeat
CLRSCR;
writeln('1) Setup');
writeln('2) New Student');
writeln('3) Statistics');
writeln('4) Exit');
readln(choice);
case choice of
'1':setup;
'2':enterstudent;
'3':;
end;
until choice = '4';
End;
begin
loaddata;
mainmenu;
end.
The procedure for the data to be loaded in is called loaddata and has already been put in. Could somebody please help me write this procedure?
Many Thanks for your efforts,
Ed