From Appmethod Libraries
Jump to: navigation, search

Object Pascal

function GetEnumValue(TypeInfo: PTypeInfo; const Name: string): Integer;


extern DELPHI_PACKAGE int __fastcall GetEnumValue(PTypeInfo TypeInfo, const System::UnicodeString Name);


Type Visibility Source Unit Parent
function public
System.TypInfo System.TypInfo


Returns the value of an enumerated type constant given its string representation.

Use GetEnumValue to convert the string that represents an enumerated value into the corresponding integer that is its implemented value.

TypeInfo is the type information record that describes the enumerated type. You can obtain the type information for a type by calling the TypeInfo function in Object Pascal or using the __delphirtti operator in C++.

The Name argument should contains a string representation of an enumerated type constant. GetEnumValue uses a case-insensitive match.

GetEnumValue returns the corresponding integer value, or -1 if Name does not match any constant in the supplied TypeInfo.

Sample syntax:

 I := System.TypInfo.GetEnumValue(TypeInfo(TAbc), 'abcSomeOption');

See Also