[SOLVED]Query all enum value names through RTTI lazarus / 62-General ---------------------------------------------------------------------- soerensen3 · 2018-05-24 23:09 Hi, I try to get all possible values for an enum for my custom object inspector (In OpenGL so I can't use the LCL one). So from that Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i TTestEnum = ( value1, value2, value3 );  I want a stringlist with the lines 'value1', 'value2', 'value3'. This code works for the enum above: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   if ( FPropInfo^.PropType^.Kind in [ tkEnumeration, tkBool ]) then    begin      Result:= TStringList.Create;      for i:= 0 to GetEnumNameCount( FPropInfo^.PropType ) - 1 do        Result.Add( GetEnumName( FPropInfo^.PropType, i ));      WriteLn( Result.Text );    end  else  Result:= nil;  But for this enum it does not work. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i TTestEnum2 = ( value1, value5 = 5, value7 = 7 ); // does only return value1  Does anyone know a solution or should I not use this kind of enum? ---------------------------------------------------------------------- soerensen3 · 2018-05-24 23:48 Found the solution, in case anyone needs this as well: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function EnumGetNames( FPropInfo: PPropInfo ): TStringList;var  PS : PShortString;  i, Count: Integer;  s: String;begin  case ( FPropInfo^.PropType^.Kind ) of    tkEnumeration:      with GetTypeData( FPropInfo^.PropType )^ do begin        PS:= @NameList;      Count:= 0;         Result:= TStringList.Create;        While ( PByte( PS )^ <> 0 ) do begin          Result.Add( PS^ );          PS:= PShortString( Pointer( PS ) + PByte( PS )^ + 1 );          Inc( Count );        end;         Result.Delete( Result.Count - 1 ); // Last line is the unit name      end;    tkBool: begin      Result:= TStringList.Create;      Result.Text:= 'False' + LineEnding + 'True';    end  else    Result:= nil;  end;end;