Runtime Type Information (RTTI)

From Lazarus wiki
Revision as of 15:55, 24 March 2012 by Vincent (talk | contribs) (Text replace - "delphi>" to "syntaxhighlight>")

RTTI can be utilized to obtain a number of meta information in a Pascal application.

Converting a enumerated type to a string

One can use RTTI to obtain a string from a enumerated type.

  TProgrammerType = (tpDelphi, tpVisualC, tpVB, tpJava) ;

uses TypInfo;

  s: string;
  s := GetEnumName(TypeInfo(TProgrammerType), integer(tpDelphi));
  // Here s = 'tpDelphi'

See Also