测试项目1的数据:BU:SINGLE,WU(X,Y:INTEGER) 一共有6个数据,第0个是根据1-5计算出来的测试项目2,3的数据:X,Y:INTEGER 一共有6个数据,第0个是根据1-5计算出来的测试项目4-9的数据:dy:SINGLE 只有一个数据 TBuWuRG=record x:integer; y:integer; dy:single; end; TMyBuWuRG=array [0..5] of TBuWuRG; TData = record case ProjType:integer of 1,2,3:(BuWuRG:array [1..3] of TMyBuWuRG); 4,5,6,7,8,9:(dy:array [4..9] of single); end; 这样定义为了程序中赋值及访问比较方面了.procedure TForm1.Button1Click(Sender: TObject); begin ProjRec.ProjType :=1; ProjRec.BuWuRG[1][0].x:=1; ProjRec.ProjType :=4; //指定这两条之后值就不对 ProjRec.dy[4]:=4;ProjRec.ProjType :=1; ShowMessage(IntToStr(ProjRec.BuWuRG[1][0].x));如果是[1][0]不行,而如果是[1][1..5]倒是可以? 为什么? 帮我一下!TKS!
unit 中的一部分:主要根据ProjNum(1..9)项目 及 键盘的击键 访问变量数组var:TDATA; ProjRec case ProjNum of 1,2,3: begin if (Key in [VK_NUMPAD1..VK_NUMPAD5]) then begin With ProjRec do begin ProjType:= ProjNum; BuWuRG[ProjNum][Key-VK_NUMPAD0].x :=StrToInt(xlab.caption); BuWuRG[ProjNum][Key-VK_NUMPAD0].y :=StrToInt(ylab.caption); BuWuRG[ProjNum][Key-VK_NUMPAD0].dy :=StrToFloat(dylab.caption); if (Key=VK_NUMPAD5) then begin xCacu.IniMaxMinZero; yCacu.IniMaxMinZero; dyCacu.IniMaxMinZero; for i:=1 to 5 do begin xMaxMin:=xCacu.MaxMin(ABS(BuWuRG[ProjNum][i].x-BuWuRG[ProjNum][3].x)); yMaxMin:=yCacu.MaxMin(ABS(BuWuRG[ProjNum][i].y-BuWuRG[ProjNum][3].y)); dyMaxMin:=dyCacu.MaxMin(ABS(BuWuRG[ProjNum][i].dy-BuWuRG[ProjNum][3].dy)); end; BuWuRG[ProjNum][0].x :=StrToInt(xMaxMin[0]); BuWuRG[ProjNum][0].y :=StrToInt(yMaxMin[0]); BuWuRG[ProjNum][0].dy :=StrToFloat(dyCacu.MinDivMax); ShowMessage(IntToStr(ProjRec.BuWuRG[ProjNum][0].x)); Subx.Caption :=xMaxMin[0]; Suby.Caption :=yMaxMin[0]; bu.Caption :=dyMaxMin[0]+'%'; end; end; end; end; 4,5,6,7,8,9: begin if (Key=VK_NUMPAD6) then begin with ProjRec do begin ProjType:= ProjNum; dy[ProjNum]:=StrToFloat(dylab.Caption); end; end; end;
TBuWuRG=record x:integer; y:integer; dy:single; end; TMyBuWuRG=array [0..5] of TBuWuRG; TData = record case ProjType:integer of 1,2,3:(BuWuRG:array [1..3] of TMyBuWuRG); 4,5,6,7,8,9:(dy:array [4..9] of single); end; 这样定义为了程序中赋值及访问比较方面了.其实就是可变记录的定义与访问的问题?这样定义会有问题吗?
http://www.delphibbs.com/delphibbs/dispq.asp?lid=1126334
我上不了DelphiBBS~~~帮不了你了~QQ中也显示不了你的```
一共有6个数据,第0个是根据1-5计算出来的测试项目2,3的数据:X,Y:INTEGER
一共有6个数据,第0个是根据1-5计算出来的测试项目4-9的数据:dy:SINGLE
只有一个数据 TBuWuRG=record
x:integer;
y:integer;
dy:single;
end; TMyBuWuRG=array [0..5] of TBuWuRG; TData = record
case ProjType:integer of
1,2,3:(BuWuRG:array [1..3] of TMyBuWuRG);
4,5,6,7,8,9:(dy:array [4..9] of single);
end;
这样定义为了程序中赋值及访问比较方面了.procedure TForm1.Button1Click(Sender: TObject);
begin
ProjRec.ProjType :=1;
ProjRec.BuWuRG[1][0].x:=1; ProjRec.ProjType :=4; //指定这两条之后值就不对
ProjRec.dy[4]:=4;ProjRec.ProjType :=1;
ShowMessage(IntToStr(ProjRec.BuWuRG[1][0].x));如果是[1][0]不行,而如果是[1][1..5]倒是可以?
为什么?
帮我一下!TKS!
ProjRec case ProjNum of
1,2,3:
begin if (Key in [VK_NUMPAD1..VK_NUMPAD5]) then
begin With ProjRec do
begin
ProjType:= ProjNum;
BuWuRG[ProjNum][Key-VK_NUMPAD0].x :=StrToInt(xlab.caption);
BuWuRG[ProjNum][Key-VK_NUMPAD0].y :=StrToInt(ylab.caption);
BuWuRG[ProjNum][Key-VK_NUMPAD0].dy :=StrToFloat(dylab.caption); if (Key=VK_NUMPAD5) then
begin
xCacu.IniMaxMinZero;
yCacu.IniMaxMinZero;
dyCacu.IniMaxMinZero; for i:=1 to 5 do
begin
xMaxMin:=xCacu.MaxMin(ABS(BuWuRG[ProjNum][i].x-BuWuRG[ProjNum][3].x));
yMaxMin:=yCacu.MaxMin(ABS(BuWuRG[ProjNum][i].y-BuWuRG[ProjNum][3].y));
dyMaxMin:=dyCacu.MaxMin(ABS(BuWuRG[ProjNum][i].dy-BuWuRG[ProjNum][3].dy));
end;
BuWuRG[ProjNum][0].x :=StrToInt(xMaxMin[0]);
BuWuRG[ProjNum][0].y :=StrToInt(yMaxMin[0]);
BuWuRG[ProjNum][0].dy :=StrToFloat(dyCacu.MinDivMax); ShowMessage(IntToStr(ProjRec.BuWuRG[ProjNum][0].x)); Subx.Caption :=xMaxMin[0];
Suby.Caption :=yMaxMin[0];
bu.Caption :=dyMaxMin[0]+'%'; end;
end;
end;
end;
4,5,6,7,8,9:
begin
if (Key=VK_NUMPAD6) then
begin with ProjRec do
begin
ProjType:= ProjNum;
dy[ProjNum]:=StrToFloat(dylab.Caption);
end;
end;
end;
x:integer;
y:integer;
dy:single;
end; TMyBuWuRG=array [0..5] of TBuWuRG; TData = record
case ProjType:integer of
1,2,3:(BuWuRG:array [1..3] of TMyBuWuRG);
4,5,6,7,8,9:(dy:array [4..9] of single);
end;
这样定义为了程序中赋值及访问比较方面了.其实就是可变记录的定义与访问的问题?这样定义会有问题吗?