unit GlobalSetting;interface
uses
Windows, Messages, SysUtils, Variants, Classes;
type
TCondition=Record
Field:String;
Operator:String;
Value:String;
end;
TConditions=class(TObject)
private
FCount:Integer;
FConditions:Array of TCondition;
function GetCondition(Index: Integer): TCondition;
function GetCount:Integer;
protected
public
procedure Add(Condition: TCondition);
property Items[Index:Integer]:TCondition read GetCondition;
property Count:Integer read FCount;
constructor Create;overload;
destructor destroy;override;
end;implementation{ TConditions }function TConditions.GetCondition(Index: Integer): TCondition;
begin
If Index>FCount-1 then
begin
MessageBox(0,'索引值大于最大值','错误',mb_Ok+mb_IconError);
Exit;
end;
if Index<0 then
begin
MessageBox(0,'索引值不能小于0','错误',mb_Ok+mb_IconError);
Exit;
end;
Result:=FConditions[Index];
end;procedure TConditions.Add(Condition: TCondition);
begin
FCount:=Length(FConditions);
SetLength(FConditions,FCount+1);
FConditions[FCount]:=Condition;
FCount:=FCount+1;
end;function TConditions.GetCount: Integer;
begin
FCount:=Length(FConditions);
Result:=FCount;
end;destructor TConditions.destroy;
begin
SetLength(FConditions,0);
inherited;
end;constructor TConditions.Create;
begin
FCount:=0;
SetLength(FConditions,FCount);//运行到这句出错,到底是怎么回事???难道设置数组大小不是这个函数????、
求教了
谢谢
end;
uses
Windows, Messages, SysUtils, Variants, Classes;
type
TCondition=Record
Field:String;
Operator:String;
Value:String;
end;
TConditions=class(TObject)
private
FCount:Integer;
FConditions:Array of TCondition;
function GetCondition(Index: Integer): TCondition;
function GetCount:Integer;
protected
public
procedure Add(Condition: TCondition);
property Items[Index:Integer]:TCondition read GetCondition;
property Count:Integer read FCount;
constructor Create;overload;
destructor destroy;override;
end;implementation{ TConditions }function TConditions.GetCondition(Index: Integer): TCondition;
begin
If Index>FCount-1 then
begin
MessageBox(0,'索引值大于最大值','错误',mb_Ok+mb_IconError);
Exit;
end;
if Index<0 then
begin
MessageBox(0,'索引值不能小于0','错误',mb_Ok+mb_IconError);
Exit;
end;
Result:=FConditions[Index];
end;procedure TConditions.Add(Condition: TCondition);
begin
FCount:=Length(FConditions);
SetLength(FConditions,FCount+1);
FConditions[FCount]:=Condition;
FCount:=FCount+1;
end;function TConditions.GetCount: Integer;
begin
FCount:=Length(FConditions);
Result:=FCount;
end;destructor TConditions.destroy;
begin
SetLength(FConditions,0);
inherited;
end;constructor TConditions.Create;
begin
FCount:=0;
SetLength(FConditions,FCount);//运行到这句出错,到底是怎么回事???难道设置数组大小不是这个函数????、
求教了
谢谢
end;
解决方案 »
- 呼唤阿发伯大侠,请问PS里面的调整,黑白,计算原理是什么?
- 庆祝五一
- 对你绝对有帮助
- 请问如何只启动一个进程?
- 在Delphi7.0中怎样建立报表
- 高手救命,关于ado连接sqlserver失败的问题
- 谁能给我解释一下句柄是什么?是做什么用的?
- 送分了-----一个简单的SQL查询!!!
- 再次求解!!!急急急!!!(高分相赠!!)我想做一个对指定的网页填写数据的程序,因为该网页每次只能填写一条记录,并且是用asp写的,因此我想把所以得数据填入一个数据库,然后由程序在网上一一填写,请各位大侠指点如何实现?如何编写?用什么原理?
- 在WIN2000下如何使用/用何API函数能够屏蔽系统热键
- 关于Treeview界面和业务分离的问题
- 怎么动态控制DBGRID的字段?
begin
a.create;//这里就错
end;
好像是错在SETLENGTH上面
运行到fcount:=0的时候,FCOUNT的值是一个20000多的大整数
把FCOUNT赋值为0后,再运行SETLENGTH就报错
我记得以前看过一篇文章,说的好像是动态数组在初始化的时候,长度并不是0,而是一个随机数,不知道是不是这样的原因
如果是,又该如何解决呢
我现在有好几个类用了类似的数组处理
如果解决不了,好多东西就要重来了
谢谢大家
var a:Tconditions;
begin
a := TConditions.Create;//这里就错
// 后面释放。
end;
难道不是
a:=TCondition.create?????
看你二楼的引用:
var a:Tconditions;
begin
a.create;//这里就错
end;
犯了一个无比愚蠢的错误!!太丢人啦!
还是
Dlwxn(蓝天)眼睛尖
感谢感谢
同时接受一个教训
CODE一定要细心
细心
再细心!
begin
a := Tconditions.create;//这里就错 我靠.还有你那种写法!
end;
begin
inherited; //加上这句,整个世界安静了。
FCount:=0;
SetLength(FConditions,FCount);
end;