fork download
  1. {$mode objfpc}
  2. {$M+}
  3.  
  4. uses typinfo;
  5.  
  6. type
  7. TRoosters = (GoldenRooster, Junglefowl, FightingCock, Fjalarr, Gullinkambi, GallicRooster, You);
  8.  
  9. TTestPituh = class(TObject)
  10. private
  11. TestField: TRoosters;
  12. published
  13. property TestProp: TRoosters read TestField write TestField;
  14. end;
  15.  
  16. function GetRoosterName(x: TRoosters): string;
  17. Var
  18. O : TTestPituh;
  19. begin
  20. O := TTestPituh.Create;
  21. GetRoosterName := GetEnumName(GetPropInfo(O,'TestProp')^.PropType, Ord(x));
  22. O.Destroy
  23. end;
  24.  
  25. begin
  26. Writeln(GetRoosterName(FightingCock))
  27. end.
Success #stdin #stdout 0s 660KB
stdin
Standard input is empty
stdout
FightingCock