Y
yepemig
Unregistered / Unconfirmed
GUEST, unregistred user!
我写了一个这样的类:
TCustomInfo = Class(TObject)
private
FID: Variant;
FNo: String;
FName: String;
FDataSet: TSmartDataSet;
//这个是继承自TClientDataSet
procedure SetID(const Value: Variant);
protected
procedure SetInfoByID(const Value: Variant);
virtual;
public
constructor Create(ASQL: string);
virtual;
destructor Destroy;
override;
function LocateByID(const AID: Variant;
bSync: Boolean = False): Boolean;
function IDByNo(const ANo: string): Variant;
virtual;
function NameByNo(const ANo: string): String;
virtual;
function NoByID(const AID: Variant): String;
virtual;
function NameByID(const AID: Variant): string;
virtual;
function IDString: string;
procedure Clear;
virtual;
property DataSet: TSmartDataSet read FDataSet;
published
Property ID: Variant read FID write SetID;
property No: String read FNo;// write FNo;
property Name: String read FName;// write FName;
end;
其中的 procedure Clear;
virtual;
函数的内容是:
procedure TCustomInfo.Clear;
var
i: Integer;
Properties : PPropList;
begin
for i := 0 to GetPropList(Self, Properties) - 1do
begin
case PropType(Self, Properties.Name) of
//tkClass: SetObjectProp(Self, Properties, nil);
//SetMethodProp(Self, Properties, null);
{tkMethod, }tkVariant, tkRecord, tkArray, tkDynArray, tkInterface: SetPropValue(Self, Properties.Name, null);
tkInteger, tkFloat, tkInt64, tkEnumeration, tkSet: SetPropValue(Self, Properties.Name, 0);
tkChar, tkWChar, tkString, tkLString, tkWString: SetPropValue(Self, Properties.Name, '');
end;
end;
end;
我运行调试时, 执行到for i := 0 to GetPropList(Self, Properties) - 1do
这句就出地址错误了,
即GetPropList(Self, Properties)出地址错误.
但我GetPropList(Self.DataSet, Properties)时这句是不会出错的.
请问各位大侠, 为什么会这样的?
TCustomInfo = Class(TObject)
private
FID: Variant;
FNo: String;
FName: String;
FDataSet: TSmartDataSet;
//这个是继承自TClientDataSet
procedure SetID(const Value: Variant);
protected
procedure SetInfoByID(const Value: Variant);
virtual;
public
constructor Create(ASQL: string);
virtual;
destructor Destroy;
override;
function LocateByID(const AID: Variant;
bSync: Boolean = False): Boolean;
function IDByNo(const ANo: string): Variant;
virtual;
function NameByNo(const ANo: string): String;
virtual;
function NoByID(const AID: Variant): String;
virtual;
function NameByID(const AID: Variant): string;
virtual;
function IDString: string;
procedure Clear;
virtual;
property DataSet: TSmartDataSet read FDataSet;
published
Property ID: Variant read FID write SetID;
property No: String read FNo;// write FNo;
property Name: String read FName;// write FName;
end;
其中的 procedure Clear;
virtual;
函数的内容是:
procedure TCustomInfo.Clear;
var
i: Integer;
Properties : PPropList;
begin
for i := 0 to GetPropList(Self, Properties) - 1do
begin
case PropType(Self, Properties.Name) of
//tkClass: SetObjectProp(Self, Properties, nil);
//SetMethodProp(Self, Properties, null);
{tkMethod, }tkVariant, tkRecord, tkArray, tkDynArray, tkInterface: SetPropValue(Self, Properties.Name, null);
tkInteger, tkFloat, tkInt64, tkEnumeration, tkSet: SetPropValue(Self, Properties.Name, 0);
tkChar, tkWChar, tkString, tkLString, tkWString: SetPropValue(Self, Properties.Name, '');
end;
end;
end;
我运行调试时, 执行到for i := 0 to GetPropList(Self, Properties) - 1do
这句就出地址错误了,
即GetPropList(Self, Properties)出地址错误.
但我GetPropList(Self.DataSet, Properties)时这句是不会出错的.
请问各位大侠, 为什么会这样的?