Return to MarkChrisSoft home page
{---------------------------------------------------------}
procedure Save(Name,Address,Phone: ArrayType);
{---------------------------------------------------------}
var
i: integer;
fdat : text;
begin
assign(fdat,'address.dat'); {Give the text variable a
real file name}
{saving the file}
{$I-} {Open the file for writing to,
rewrite(fdat); with the input checking off}
{$I+}
if IOResult=0 then {File opened OK}
begin
for i:=1 to maxNames do
begin
writeln(fdat,Name[i]); {Writing to the text file}
writeln(fdat,Address[i]);
writeln(fdat,Phone[i]);
end;
close(fdat); {Opened files must be closed}
end
else Warning ('An error has occurred whilst saving! Is your disc full?');
end; {Save procedure}
{---------------------------------------------------------}
procedure Load(var Name,Address,Phone: ArrayType);
{---------------------------------------------------------}
var
i: integer;
fdat : text;
begin
assign(fdat,'address.dat'); {Give the text variable a
real file name}
{loading the file}
{$I-} {Open the file for reading,
reset(fdat); with the input checking off}
{$I+}
if IOResult=0 then {File opened OK}
begin
for i:=1 to maxNames do
begin
readln(fdat,Name[i]); {Writing to the text file}
readln(fdat,Address[i]);
readln(fdat,Phone[i]);
end;
close(fdat); {Opened files must be closed}
end
else Warning ('File not found!');
end; {Save procedure}
Author: Mark Baker, e-mail mbaker@rmplc.co.uk