C
chenxiu
Unregistered / Unconfirmed
GUEST, unregistred user!
下面是我的一段代码,我的本意是每次调用Test过程就给x和y数组补零到长度l,但是我发现在过程中用setlength函数老是出错!下面的代码运行时 就出错!请高手指点!
procedure Test(Var x,y:array of real;m,n,l:integer);
var
i:integer;
xx,yy:array of real;
begin
SetLength(xx,l);
SetLength(yy,l);
for i:=1 to m do xx:=x;
for i:=m+1 to l do xx:=0;
for i:=1 to n do yy:=y;
for i:=n+1 to l do yy:=0;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
i,m,n,l:integer;
x,y:array of real;
begin
m:=3;
n:=4;
Setlength(x,m);
Setlength(y,n);
x[1]:=1;x[2]:=2;x[3]:=3;
y[1]:=1;y[2]:=2;y[3]:=3;y[4]:=4;
Test(x,y,m,n,l);
for i:=1 to m do
begin
Memo1.Lines.Add(floattostr(x));
end;
end;
procedure Test(Var x,y:array of real;m,n,l:integer);
var
i:integer;
xx,yy:array of real;
begin
SetLength(xx,l);
SetLength(yy,l);
for i:=1 to m do xx:=x;
for i:=m+1 to l do xx:=0;
for i:=1 to n do yy:=y;
for i:=n+1 to l do yy:=0;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
i,m,n,l:integer;
x,y:array of real;
begin
m:=3;
n:=4;
Setlength(x,m);
Setlength(y,n);
x[1]:=1;x[2]:=2;x[3]:=3;
y[1]:=1;y[2]:=2;y[3]:=3;y[4]:=4;
Test(x,y,m,n,l);
for i:=1 to m do
begin
Memo1.Lines.Add(floattostr(x));
end;
end;