Информатика. Программирование в Delphi
294
i,j:word;
f:textfile;
begin
currfile:=path;
AssignFile(f,path);
Rewrite(f);
writeln(f,Form1.StringGrid1.ColCount);
writeln(f,Form1.StringGrid1.RowCount);
for i:=1 to Form1.StringGrid1.RowCount-1 do
for j:=0 to Form1.StringGrid1.ColCount-1 do
writeln(f,Form1.StringGrid1.Cells[j,i]);
CloseFile(f);
end;
procedure loadfromfile(path:string);
var
i,j:word;
f:textfile;
s:string;
begin
currfile:=path;
AssignFile(f,path);
Reset(f);
readln(f,s);
Form1.StringGrid1.ColCount:=StrToInt(s);
readln(f,s);
Form1.StringGrid1.RowCount:=StrToInt(s);
for i:=1 to Form1.StringGrid1.RowCount-1 do
for j:=0 to Form1.StringGrid1.ColCount-1 do
begin
readln(f,s);
Form1.StringGrid1.Cells[j,i]:=s;
end;
CloseFile(f);
end;
procedure TForm1.FormCreate(Sender: TObject);
var
f:TextFile;
s:string;
begin
currdir:=GetCurrentDir;
currfile:='';
Form1.Caption:='Телефонный справочник';
Form1.BorderStyle:=bsSingle;