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

Frank Church vfclists at gmail.com
Sun Sep 12 12:17:00 CEST 2010

```On 30 August 2010 11:30, Frank Church <vfclists at gmail.com> wrote:

> Is there a subroutine that can convert an enum value to a strings, so that
> I can do something like ShowMessage(EnumToStr(enumValue))?
>
> --
>
program testnums;
//{\$APPTYPE CONSOLE}

uses
Classes, SysUtils;
type
stType =3D (stLite :=3D -100, stDb, stBothLite, stBothDb); //settings
location Type

var
d : stType;
s : string;
i : integer;
begin

d:=3D stLite;
writestr(s,d);
writeln(s + ' ' + IntToStr(Integer(d)));

d:=3D stDb;
writestr(s,d);
writeln(s + ' ' + IntToStr(Integer(d)));

d:=3D stBothLite;
writestr(s,d);
writeln(s + ' ' + IntToStr(Integer(d)));

d:=3D stBothDB;
writestr(s,d);
writeln(s + ' ' + IntToStr(Integer(d)));

end.

This is the code I created, as enums are stored as integers, or  QWORDs,
what is the default way of displaying the integer value of an enum.

Frank Church
>
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> http://devblog.brahmancreations.com
>

-- =

Frank Church

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
http://devblog.brahmancreations.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freepascal.org/lists/fpc-pascal/attachments/20100912/6c94=
d7cf/attachment.htm
```