Enum degraded or spec changed with Build 324?

 

I made a simple test script.

//+------------------------------------------------------------------+
//|                                                     testEnum.mq5 |
//+------------------------------------------------------------------+
enum ENUM_TEST_CODE
  {
   CODE_ZERO,
   CODE_ONE,
   CODE_TWO
  };
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//--- expect to print out number 3
   Print(getCode("0")+getCode("1")+getCode("2"));
//--- expect to print out string "012"
   Print((string)getCode("0")+(string)getCode("1")+(string)getCode("2"));
  }
//+------------------------------------------------------------------+
//| User-defined function                                            |
//+------------------------------------------------------------------+
ENUM_TEST_CODE getCode(string textcode)
  {
   if(textcode=="0") return(CODE_ZERO);
   if(textcode=="1") return(CODE_ONE);
   if(textcode=="2") return(CODE_TWO);
   return(CODE_ZERO);
  }
//+------------------------------------------------------------------+

And results are like this:

2010.09.10 00:19:00 testEnum (EURUSD,M5) 3 < correct.
2010.09.10 00:19:00 testEnum (EURUSD,M5) 260830442608302026082984 < incorrect... I expected string "012".
 

 

Well, I'm not sure whether actually casting a string from an enumeration through the cast operator is the preferred MQL5 way of doing things.

Though it's not so orthogonal, use: IntegerToString() instead. 

 

Thanks, Plymo, for your reply.

If it will be clear that the spec was changed, I will use IntegerToString().

 
Micky:

I made a simple test script.

And results are like this:

2010.09.10 00:19:00 testEnum (EURUSD,M5) 3 < correct.
2010.09.10 00:19:00 testEnum (EURUSD,M5) 260830442608302026082984 < incorrect... I expected string "012".
 

Thank you for your message. Buh fixed. Please wait for updates.