[Overview][Constants][Types][Classes][Procedures and functions] |
Return value of an object-type property.
Source position: line 0
function GetObjectProp( |
Instance: TObject; |
const PropName: String |
):TObject; |
Instance: TObject; |
const PropName: String; |
MinClass: TClass |
):TObject; |
Instance: TObject; |
PropInfo: PPropInfo |
):TObject; |
Instance: TObject; |
PropInfo: PPropInfo; |
MinClass: TClass |
):TObject; |
GetObjectPropreturns the object which the property described by PropInfowith name Propnamepoints to for object Instance.
If MinClassis specified, then if the object is not descendent of class MinClass, then Nilis returned.
No checking is done whether Instanceis non-nil, or whether PropInfodescribes a valid method property of Instance. Specifying an invalid property name in PropNamewill result in an EPropertyErrorexception.
|
Set the value of a method property |
|
|
Get the value of an ordinal property |
|
|
Return the value of a string property. |
|
|
Return value of floating point property |
|
|
return value of an Int64 property |
|
|
Return the value of a set property. |
|
|
Return value of an object-type property. |
|
|
Return the value of an enumeration type property. |
program example5; { This program demonstrates the GetObjectProp function } {$mode objfpc} uses rttiobj,typinfo; Var O : TMyTestObject; PI : PPropInfo; NO1,NO2 : TNamedObject; begin O:=TMyTestObject.Create; NO1:=TNamedObject.Create; NO1.ObjectName:='First named object'; NO2:=TNamedObject.Create; NO2.ObjectName:='Second named object'; O.ObjField:=NO1; Writeln('Object property : '); PI:=GetPropInfo(O,'ObjField'); Write('Property class : '); Writeln(GetObjectPropClass(O,'ObjField').ClassName); Write('Value : '); Writeln((O.ObjField as TNamedObject).ObjectName); Write('Get (name) : '); Writeln((GetObjectProp(O,'ObjField') As TNamedObject).ObjectName); Write('Get (propinfo) : '); Writeln((GetObjectProp(O,PI,TObject) as TNamedObject).ObjectName); SetObjectProp(O,'ObjField',NO2); Write('Set (name,NO2) : '); Writeln((O.ObjField as TNamedObject).ObjectName); SetObjectProp(O,PI,NO1); Write('Set (propinfo,NO1) : '); Writeln((O.ObjField as TNamedObject).ObjectName); O.Free; end.