[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 = (stLite := -100, stDb, stBothLite, stBothDb); //settings
location Type
var
d : stType;
s : string;
i : integer;
begin
d:= stLite;
writestr(s,d);
writeln(s + ' ' + IntToStr(Integer(d)));
d:= stDb;
writestr(s,d);
writeln(s + ' ' + IntToStr(Integer(d)));
d:= stBothLite;
writestr(s,d);
writeln(s + ' ' + IntToStr(Integer(d)));
d:= stBothDB;
writestr(s,d);
writeln(s + ' ' + IntToStr(Integer(d)));
readln;
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
>
> =======================
> http://devblog.brahmancreations.com
>
--
Frank Church
=======================
http://devblog.brahmancreations.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20100912/6c94d7cf/attachment.html>
More information about the fpc-pascal
mailing list