[fpc-pascal] How can you convert an enum value to string?

Michael Van Canneyt michael at freepascal.org
Mon Aug 30 15:04:39 CEST 2010



On Mon, 30 Aug 2010, Frank Church wrote:

> Is there a subroutine that can convert an enum value to a strings, so that I
> can do something like ShowMessage(EnumToStr(enumValue))?

Just use writestr ?

program testw;

type
   mytype = (a,b,c);

var
   d : mytype;
   s : string;

begin
  d:=a;
  writestr(s,d);
  writeln(s);
end.

This works in trunk, and I think that even str() works with enumerateds in
trunk.

Michael.



More information about the fpc-pascal mailing list