[fpc-pascal] Something like g_object_get() in Pascal?

Felipe Monteiro de Carvalho felipemonteiro.carvalho at gmail.com
Mon Aug 2 10:43:49 CEST 2010

On Sun, Aug 1, 2010 at 2:45 PM, Matthias Klumpp <matthias at nlinux.org> wrote:
> Is there a possibility to get the same function in Pascal to? That I just
> define one get_value() function which receives the property name as string
> and outputs the value of it?

I don't know about getting the value of a property, but you can get
the type of a property using RTTI:

Read more here:


function GetPropInfo(TypeInfo: PTypeInfo;
  const PropName: string): PPropInfo;

You would need to change your record into a class:

TTestClass = class
 Fval1: String;
 Fval2: Integer;
 property val1: String read Fval1 write Fval1;
 property val2: Integer read Fval2 write Fval2;

Probably this mechanism also allows to get the value of the property,
although I am not sure ...

Felipe Monteiro de Carvalho

More information about the fpc-pascal mailing list