Getting enumnum of an enum as an anytype

Hi All! I was wondering of someone here could help me out. I’m trying to obtain the enum ID number from an enum stored within an anytype (ie. an element within a container) for comparison with the return of enumnum(). Where I’m going with this is something along the lines of this:

Anytype someEnum = NoYes::Yes;

switch (/* something here to get the enumnum of "someEnum" */) {
 case enumnum(NoYes):
   /* ... */

I’ve been searching for some time now, is there anyway of doing this, something I’ve missed here? Cheers, - Simon

HI, I have found this solution for you (must use DictEnum class): Anytype someEnum = NoYes::Yes; DictEnum dictEnum = new DictEnum(someEnum); ; switch ( { … Best regards, Ciprian

Hi Ciprian, That’s probably the only thing I didn’t try - when I looked at DictEnum usage, I didn’t realise you could use an anytype. I’ll give it a go now. Thanks heaps for your help! Cheers, - Simon

Hi! This didn’t work. Change NoYes::Yes to NoYes::No and you’ll have a closer understanding of what’s goingo n. The problem is, the AnyType is being converted to the enum type as an integer (so the enum’s integral value) – this means that using the DictEnum constructor with the AnyType is unreliable. Using NoYes::No (value of 0) fails to construct the DictEnum instance. Oops. So I’m back to square one here. Surely there’s a built in (kernel) function for this? Cheers, - Simon

Hmm, looks you are right! My mistake, then. Anyway, whether it does exist or not, I think you can work this out in a different way. Instead of keeping the values into a container, why not saving into a Map foundation class variable, and map each value against the num of the Enum? Hope this helps… Ciprian