Runtime Type Information (RTTI)
From Free Pascal wiki
Revision as of 10:20, 17 July 2016 by FPC user (talk | contribs) (→Converting a enumerated type to a string: move uses clause to the top.)
│ English (en) │ français (fr) │ русский (ru) │
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.