Searching for the answer to this question has thrown up loads of answers, all of which have left me even more confused...
Some of the answers seems quite old, and its seems that later versions of FPC may well have provided a quick and easy way to do this, but I still can;t figure out what would appear to be a simple thing.
If I have an
enum such as:
type
TthreeColors = (red,green,blue);
and I create a a variable of that type to contain one of those colors:
var myFavouriteColor: TthreeColors;
I can set myFavourite color with:
If I then want to get a string representation of this (to save to an XML config file in my case, but could be used for many things) how would I do this?
settingsXML.WriteString('favouriteColor',myFavouriteColor);
doesn't work as
WriteString is expecting a type
String but getting a type
TthreeColors.
I've found references to
GetEnumName and
GetEnumValue in
typinfo but can't work out if these are the right functions to do this...
-FM