H
howard.yao
Unregistered / Unconfirmed
GUEST, unregistred user!
大家帮忙看一下可以这样定义数据和数组吗? 有没些好的建议?
type
Buysend=Record
amt:double;
buy:integer;
send:integer;
scale:double;
SendNum:integer;
tag:integer;
end ;
TBuySend=array of BuySend;
var
BSList:array of TBuySend;
我是想对之后生成的每组TBuySend 的数值进行比较,把数值一样的进行累加。
比如比较如下:
function TForm1.BSCompare(bs1,bs2:TBuySend):boolean;
var
i:integer;
begin
result:=false;
if length(bs1) <>length(bs2) then
Exit;
for i:=0 to length(bs1)-1do
begin
if (bs1.buy <>bs2.buy) or (bs1.send <>bs2.send) then
Exit;
end;
result:=true;
end;
我是如下测试的,结果是true,正确的应该是false;大家帮忙解决一下阿
procedure TForm1.Button3Click(Sender: TObject);
var
i,j:integer;
bs1,bs2 :buysend;
bsa,bsb:tbuysend;
begin
bs1.buy:=100;
bs1.send:=200;
bs2.buy:=100;
bs2.send:=100;
setlength(bsa,1);
setlength(bsb,1);
bsa[0].buy:=bs1.buy ;
bsa[1].send:=bs1.send ;
bsb[0].buy:=bs2.buy ;
bsb[1].send:=bs2.send ;
if BSCompare(bsa,bsb) then
begin
showmessage('true');
end else
begin
showmessage('false');
end;
end;
type
Buysend=Record
amt:double;
buy:integer;
send:integer;
scale:double;
SendNum:integer;
tag:integer;
end ;
TBuySend=array of BuySend;
var
BSList:array of TBuySend;
我是想对之后生成的每组TBuySend 的数值进行比较,把数值一样的进行累加。
比如比较如下:
function TForm1.BSCompare(bs1,bs2:TBuySend):boolean;
var
i:integer;
begin
result:=false;
if length(bs1) <>length(bs2) then
Exit;
for i:=0 to length(bs1)-1do
begin
if (bs1.buy <>bs2.buy) or (bs1.send <>bs2.send) then
Exit;
end;
result:=true;
end;
我是如下测试的,结果是true,正确的应该是false;大家帮忙解决一下阿
procedure TForm1.Button3Click(Sender: TObject);
var
i,j:integer;
bs1,bs2 :buysend;
bsa,bsb:tbuysend;
begin
bs1.buy:=100;
bs1.send:=200;
bs2.buy:=100;
bs2.send:=100;
setlength(bsa,1);
setlength(bsb,1);
bsa[0].buy:=bs1.buy ;
bsa[1].send:=bs1.send ;
bsb[0].buy:=bs2.buy ;
bsb[1].send:=bs2.send ;
if BSCompare(bsa,bsb) then
begin
showmessage('true');
end else
begin
showmessage('false');
end;
end;