Download MetaTrader 5

switch, case, and const int

To add comments, please log in or register
Mihai Ionescu
1589
Mihai Ionescu  

I don't know if this is a bug or not.

I read that in case there must be a constant value. 

I tried to define some constant int value, and put it into case statement like this:

const int MENU_SHOW 1;

//...

switch (menu_action) {

//...

case MENU_SHOW:
            ObjectSetInteger(0,prefix+"Edit",OBJPROP_TIMEFRAMES,OBJ_ALL_PERIODS);
            printf("menu L (1)");
            break;

//...         
}

 What was confusing was that mql5 compiled ok.

But what I wrote doesn't work.

It must be really a constant like in the manual.

Wouldn't mql5 refuse to compile in the case above? 

Get in touch with developers using Service Desk!
  • www.mql5.com
We therefore attach great importance to all user reports about issues in our programs and try to answer each one of them.
Slava
Moderator
6978
Slava  
#define MENU_SHOW 1
Alexey Da
Moderator
6620
Alexey Da  

Thank you.

We will check it. 

Mihai Ionescu
1589
Mihai Ionescu  
stringo:

Thanks for suggestion.

I thought of #define from c, but I didn't arrive to try it.

Good it's possible. 

To add comments, please log in or register