How the MQL4 enum anEnumNAME{...};
syntax works?
Well,
given you need to preserve
both the "old" enum
( the one without "d
" ) ordering
and the alphabetical-order too
only one thing is sure - you cannot use enum
as proposed above for that.
MQL4 implements enum
as a syntax sugar for registering "named constants" for the compiler phase, and translates such elements into an ordered enumeration of a new, specific data-type ( not matching other, strong-typed language data-types in compilation phase ).
Rule: If a certain value is not assigned to a named constant that is a member of the enumeration, its new value will be formed automatically. If it is the first member of the enumeration, the 0 value will be assigned to it. For all subsequent members, values will be calculated based on the value of the previous members by adding one.
This means, you cannot mix and mangle alphabet ordering and incidentally arranged sequential ordering ( as Hollywood states in trailing titles: "In the order of appearance" ).
So what can one do?
A Rainman solution ( "Go to Holbrook, with Charlie Babbit." ):
enum ENUM_myChoice{
a = uchar( "a" ),
b = uchar( "b" ),
c = uchar( "c" ),
e = uchar( "e" ),
f = uchar( "f" ),
g = uchar( "g" ),
// ----------------- WHERE ONE CAN BENEFIT AN OUT-OF-ORDINAL ORDER ADDING:
d = uchar( "d" )
};