1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
| procedure SaveMyArray(AFileName: string; ALArray: LArray);
var
i,j: integer;
Stream: TStream;
begin
Stream := TFileStream.Create(AFileName,fmCreate);
try
for i:=1 to 100 do
for j:=1 to 100 do
Stream.Write(ALArray[i,j], SizeOf(ALArray[i,j]));
finally
Stream.Free;
end;
end;
procedure LoadMyArray(AFileName: string; var ALArray: LArray);
var
i,j: integer;
Stream: TStream;
begin
Stream := TFileStream.Create(AFileName,fmOpenRead);
try
for i:=1 to 100 do
for j:=1 to 100 do
Stream.Read(ALArray[i,j], SizeOf(ALArray[i,j]));
finally
Stream.Free;
end;
end;
procedure tabletosave(var tablesave:LArray);
var i,j:integer;
begin
for i:=1 to 100 do
for j:=1 to 100 do
begin
if ((table[i,j].ec=-2) or (table[i,j].ec=-1)) then tablesave[i,j]:=trunc(table[i,j].ec);
if (table[i,j].ec=f1) then tablesave[i,j]:=1;
if (table[i,j].ec=f2) then tablesave[i,j]:=2;
if (table[i,j].ec=f3) then tablesave[i,j]:=3;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var tablesave: LArray;
begin
tabletosave(tablesave);
if SaveDialog1.Execute then
SaveMyArray(SaveDialog1.FileName,tablesave);
end;
procedure tabletoload(tablesave:LArray);
var i,j:integer;
begin
for i:=1 to 100 do
for j:=1 to 100 do
begin
if ((tablesave[i,j]=-1) or (tablesave[i,j]=-2)) then table[i,j].ec:=tablesave[i,j];
if tablesave[i,j]=1 then table[i,j].ec:=f1;
if tablesave[i,j]=2 then table[i,j].ec:=f2;
if tablesave[i,j]=3 then table[i,j].ec:=f3;
end;
end;
procedure TForm1.Button11Click(Sender: TObject);
var tablesave: LArray;
begin
if OpenDialog1.Execute then
if FileExists(OpenDialog1.FileName) then
LoadMyArray(OpenDialog1.FileName,tablesave);
tabletoload(tablesave);
colorer;
end; |
Partager