[Overview][Constants][Types][Classes][Procedures and functions] |
Return the value of a set property.
Source position: line 0
function GetSetProp( |
Instance: TObject; |
const PropName: String |
):String; |
Instance: TObject; |
const PropName: String; |
Brackets: Boolean |
):String; |
Instance: TObject; |
const PropInfo: PPropInfo; |
Brackets: Boolean |
):String; |
GetSetPropreturns the contents of a set property as a string. The property to be returned can be specified by it's name in PropNameor by its property information in PropInfo.
The returned set is a string representation of the elements in the set as returned by SetToString. The Bracketsoption can be used to enclose the string representation in square brackets.
No checking is done whether Instanceis non-nil, or whether PropInfodescribes a valid ordinal property of InstanceSpecifying an invalid property name in PropNamewill result in an EPropertyErrorexception.
|
Set value of set-typed property. |
|
|
Return the value of a string property. |
|
|
Return value of floating point property |
|
|
return value of an Int64 property |
|
|
Return value of a method property |
program example7; { This program demonstrates the GetSetProp function } {$mode objfpc} uses rttiobj,typinfo; Var O : TMyTestObject; PI : PPropInfo; Function SetAsString (ASet : TMyEnums) : String; Var i : TmyEnum; begin result:=''; For i:=mefirst to methird do If i in ASet then begin If (Result<>'') then Result:=Result+','; Result:=Result+MyEnumNames[i]; end; end; Var S : TMyEnums; begin O:=TMyTestObject.Create; O.SetField:=[mefirst,meSecond,meThird]; Writeln('Set property : '); Writeln('Value : ',SetAsString(O.SetField)); Writeln('Ord(Value) : ',Longint(O.SetField)); Writeln('Get (name) : ',GetSetProp(O,'SetField')); PI:=GetPropInfo(O,'SetField'); Writeln('Get (propinfo) : ',GetSetProp(O,PI,false)); S:=[meFirst,meThird]; SetOrdProp(O,'SetField',Integer(S)); Write('Set (name,[mefirst,methird]) : '); Writeln(SetAsString(O.SetField)); S:=[meSecond]; SetOrdProp(O,PI,Integer(S)); Write('Set (propinfo,[meSecond]) : '); Writeln(SetAsString(O.SetField)); O.Free; end.