Sign in Join
FPDoc Onlineexperiment

PropType function

In unit TypInfo

Return the type of a property.

Declaration

pascal
function PropType(Instance: TObject; const PropName: string): TTypeKind

Description

Proptype returns the type of the property PropName for a class. The class to be examined can be specified in one of 2 ways:

AClass
A class pointer.
Instance
An instance of the class.

Errors

No checks are done to ensure Instance or AClass are valid pointers. Specifying an invalid property name in PropName will result in an EPropertyError exception.

See also

Example: ex17

pascal
program example17;

{ This program demonstrates the PropType function }

{$mode objfpc}

uses rttiobj,typinfo;

Var
  O : TMyTestObject;

begin
  O:=TMyTestObject.Create;
  Writeln('Property tests    : ');
  Write('PropType(O,BooleanField)     : ');
  Writeln(TypeNames[PropType(O,'BooleanField')]);
  Write('PropType(Class,BooleanField) : ');
  Writeln(TypeNames[PropType(O.ClassType,'BooleanField')]);
  Write('PropType(O,ByteField)        : ');
  Writeln(TypeNames[PropType(O,'ByteField')]);
  Write('PropType(Class,ByteField)    : ');
  Writeln(TypeNames[PropType(O.ClassType,'ByteField')]);
  O.Free;
end.

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.