Sign in Join
FPDoc Onlineexperiment

PropIsType function

In unit TypInfo

Check the type of a published property.

Declaration

pascal
function PropIsType(Instance: TObject; const PropName: string; 
 TypeKind: TTypeKind): Boolean

Description

PropIsType returns True if the property with name PropName has type TypeKind. It returns False otherwise. The class to be examined can be specified in one of two 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: ex16

pascal
program example16;

{ This program demonstrates the PropIsType function }

{$mode objfpc}

uses rttiobj,typinfo;

Var
  O : TMyTestObject;

begin
  O:=TMyTestObject.Create;
  Writeln('Property tests    : ');
  Write('PropIsType(O,BooleanField,tkBool)     : ');
  Writeln(PropIsType(O,'BooleanField',tkBool));
  Write('PropIsType(Class,BooleanField,tkBool) : ');
  Writeln(PropIsType(O.ClassType,'BooleanField',tkBool));
  Write('PropIsType(O,ByteField,tkString)      : ');
  Writeln(PropisType(O,'ByteField',tkString));
  Write('PropIsType(Class,ByteField,tkString)  : ');
  Writeln(PropIsType(O.ClassType,'ByteField',tkString));
  O.Free;
end.

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