On Sun, Aug 1, 2010 at 2:45 PM, Matthias Klumpp <matth...@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:
http://delphi.about.com/gi/o.htm?zi=1/XJ&zTi=1&sdn=delphi&cdn=compute&tm=47&f=11&su=p284.9.336.ip_p504.1.336.ip_&tt=2&bt=1&bts=1&zu=http%3A//www.blong.com/Conferences/BorConUK98/DelphiRTTI/CB140.htm

Specifically:

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

You would need to change your record into a class:

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

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

-- 
Felipe Monteiro de Carvalho
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to