You can directly write enums with Write or WriteLn and convert enums
to strings with WriteStr.

program EnumStr;
{$mode objfpc}{$H+}

type
  TColor = (cRed, cGreen, cBlue, cYellow);

function ColorToStr(C: TColor) : String;
begin
  WriteStr(Result, C);
end;

var
  Color : TColor;
begin
  for Color in TColor do
    WriteLn(ColorToStr(Color));
end.

2011/11/1 Juha Manninen <juha.mannine...@gmail.com>:
> Hi
> I remember there is a way to get a string representation of an enumerated
> type directly without using a lookup string array, but I forgot the syntax.
> Lazarus uses only lookup arrays, maybe because the other syntax is new.
> How is the syntax?
> Juha
>
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to