Difference between revisions of "Runtime Type Information (RTTI)"

From Lazarus wiki
Jump to navigationJump to search
(→‎Converting a enumerated type to a string: move uses clause to the top.)
Line 1: Line 1:
{{Editing Runtime Type Information (RTTI)}}<p>
+
{{Editing Runtime Type Information (RTTI)}}
RTTI can be utilized to obtain a number of meta information in a Pascal application.
+
 
 +
'''Runtime Type Information RTTI''' can be utilized to obtain a number of meta information in a Pascal application.
 
__TOC__
 
__TOC__
 +
 
==Converting a enumerated type to a string==
 
==Converting a enumerated type to a string==
 
 
One can use RTTI to obtain a string from a enumerated type.
 
One can use RTTI to obtain a string from a enumerated type.
  
Line 22: Line 23:
  
 
==See Also==
 
==See Also==
 
+
*[[RTTI tab]]
 
*[[RTTI controls]]
 
*[[RTTI controls]]
 
* http://www.blong.com/Conferences/BorConUK98/DelphiRTTI/CB140.htm
 
* http://www.blong.com/Conferences/BorConUK98/DelphiRTTI/CB140.htm

Revision as of 00:06, 16 September 2016

English (en) français (fr) русский (ru)

Runtime Type Information 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.

uses TypInfo; 

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

var 
  s: string;
begin
  s := GetEnumName(TypeInfo(TProgrammerType), integer(tpDelphi));
  // Here s = 'tpDelphi'
  Writeln(s)
end.

See Also