- Регистрация
- 1 Мар 2015
- Сообщения
- 1,481
- Баллы
- 155
Objective-C:
//сохранение в файл
//procedure SaveGrid(Grid:TWrapGrid;FileName:string);
procedure SaveGrid(Grid:TStringGrid;FileName:string);
var
f: textfile;
x, y: integer;
begin
assignfile(f,Filename);
rewrite(f);
writeln(f, grid.colcount);
writeln(f, grid.rowcount);
for X := 0 to grid.colcount - 1 do
for y := 0 to grid.rowcount - 1 do
writeln(F, grid.cells[x, y]);
closefile(f);
end;
//загрузка из файла
//procedure LoadGrid(Grid:TWrapGrid;FileName:string);
procedure SaveGrid(Grid:TStringGrid;FileName:string);
var
f: textfile;
temp, x, y: integer;
tempstr: string;
begin
assignfile(f, Filename);
reset(f);
readln(f, temp);
grid.colcount := temp;
readln(f, temp);
grid.rowcount := temp;
for X := 0 to grid.colcount - 1 do
for y := 0 to grid.rowcount - 1 do
begin
readln(F, tempstr);
grid.cells[x, y] := tempstr;
end;
closefile(f);
end;
//использование
procedure TForm1.Button1Click(Sender: TObject);
begin
//SaveGrid(form1.WrapGrid1,'Grid1.txt');
SaveGrid(form1.StringGrid,'Grid1.txt');
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
//LoadGrid(form1.WrapGrid1,'Grid1.txt');
LoadGrid(form1.StringGrid,'Grid1.txt');
end;