Enumeration

Good evening,
I have an enumeration formed in this way:

DL_OK = & H0
COMMUNICATION_ERROR = & H1
CHKSUM_ERROR = & H2
EADING_ERROR = & H3
and so on for a

Since I’m translating a program from VB.NET I see that to retrieve the name of each component of the enumeration actually does this(in VB.NET):

     For Each iValue In [Enum]. GetValues ??(GetType (ErrorCodes))
         ERROR_CODES (iValue) = [Enum]. GetName (GetType (ErrorCodes), iValue)
     Next

ERROR_CODES () is a string array

How can I do likewise with XOJO? And 'possible to do so?
thanks

You can’t do that in Xojo. Enumeration elements don’t have a string representation, so there is no Enum.GetName method.

You could try using constants instead, that should work.

James,

can you explain me better? Thank you.

BR

Fabio

Actually it might be possible to do it via introspection as well. Will have a look tomorrow

Neither the enumeration name nor the constant name are available via introspection. Xojo just doesn’t have a mechanism for that. You can fake it with an array or dictionary, but it requires duplicate effort.

I solved with array!
Thank you.

BR