GetOrdProp function
Get the value of an ordinal property.
Declaration
function GetOrdProp(Instance: TObject; PropInfo: PPropInfo): Int64Description
GetOrdProp returns the value of the ordinal property described by
PropInfo or with name
PropName for the object
Instance.
The value is returned as a longint, which should be typecast to the
needed type.
Ordinal properties that can be retrieved include:
- Integers and subranges of integers
- The value of the integer will be returned.
- Enumerated types and subranges of enumerated types
- The ordinal value of the enumerated type will be returned.
- Sets
- If the base type of the set has less than 31 possible values. If a bit is set in the return value, then the corresponding element of the base ordinal class of the set type must be included in the set.
Errors
No checking is done whether
Instance is non-nil, or whether
PropInfo describes a valid ordinal property of
Instance
Specifying an invalid property name in
PropName will result in an
EPropertyError exception.
See also
Example: ex1
program example1;
{ This program demonstrates the GetOrdProp function }
{$mode objfpc}
uses rttiobj,typinfo;
Var
O : TMyTestObject;
PI : PPropInfo;
begin
O:=TMyTestObject.Create;
Writeln('Boolean property : ');
Writeln('Value : ',O.BooleanField);
Writeln('Ord(Value) : ',Ord(O.BooleanField));
Writeln('Get (name) : ',GetOrdProp(O,'BooleanField'));
PI:=GetPropInfo(O,'BooleanField');
Writeln('Get (propinfo) : ',GetOrdProp(O,PI));
SetOrdProp(O,'BooleanField',Ord(False));
Writeln('Set (name,false) : ',O.BooleanField);
SetOrdProp(O,PI,Ord(True));
Writeln('Set (propinfo,true) : ',O.BooleanField);
O.Free;
end.An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
