FindPropInfo function
Return property information by property name.
Declaration
function FindPropInfo(Instance: TObject; const PropName: string)
: PPropInfoDescription
FindPropInfo examines the published property information of a class and
returns a pointer to the property information for property
PropName.
The class to be examined can be specified in one of two ways:
- AClass
- a class pointer.
- Instance
- an instance of the class to be investigated.
If the property does not exist, a EPropertyError exception will be
raised. The GetPropInfo function has the same function as the
FindPropInfo function, but returns Nil if the property does not
exist.
Errors
Specifying an invalid property name in
PropName will result in an
EPropertyError exception.
See also
Example: ex14
Program example13;
{ This program demonstrates the FindPropInfo function }
{$mode objfpc}
uses
rttiobj,typinfo,sysutils;
Var
O : TMyTestObject;
PT : PTypeData;
PI : PPropInfo;
I,J : Longint;
PP : PPropList;
prI : PPropInfo;
begin
O:=TMyTestObject.Create;
PI:=FindPropInfo(O,'BooleanField');
Writeln('FindPropInfo(Instance,BooleanField) : ',PI^.Name);
PI:=FindPropInfo(O.ClassType,'ByteField');
Writeln('FindPropInfo(Class,ByteField) : ',PI^.Name);
Write ('FindPropInfo(Class,NonExistingProp) : ');
Try
PI:=FindPropInfo(O,'NonExistingProp');
except
On E: Exception do
Writeln('Caught exception "',E.ClassName,'" with message : ',E.Message);
end;
O.Free;
end.An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
