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

Sven Barth pascaldragon at googlemail.com
Mon Aug 30 15:14:33 CEST 2010


Am 30.08.2010 15:04, schrieb Michael Van Canneyt:
>
>
> 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.

WriteStr already worked in 2.4.0 as well.

Regards,
Sven



More information about the fpc-pascal mailing list