Is enum type integer or not?
MQL5 compiler controls type conversion - https://www.mql5.com/en/docs/basis/types/casting
Alternative, you can try this code:
Print(EnumToString(InpDayOfWeek));
Documentation on MQL5: Language Basics / Data Types / Typecasting
- www.mql5.com
Language Basics / Data Types / Typecasting - Documentation on MQL5
avoitenko:
MQL5 compiler controls type conversion - https://www.mql5.com/en/docs/basis/types/casting
Alternative, you can try this code:
Thanks for your reply, and please excuse my misleading test script.
What I really want to know is whether enum type variable is available for index of array or not.
Enum type can be converted to integer type:
Print(NAME[(int)InpDayOfWeek]);
But imagine that SUNDAY != 0 and MONDAY !=1 ..., and your code will not work.
You can use switch like this:
string DayOfWeekToString(ENUM_DAY_OF_WEEK day) { switch(day) { case SUNDAY: return("Sunday"); case MONDAY: return("Monday"); ... default:return(""); } }
I am very thankful to you for your advice.
Anyway, the problem is not the content, but the form.
My test code is only for example.
It could be compiled with previous build 5XX, but it can not be compiled with current build 540.
So, what I really want to know is whether this compile error is degradation or not.
Thank you.
Thanks a lot. It was fixed.
At this moment you better use casting like this
Print(NAME[(int)InpDayOfWeek]);
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Error message is:
'InpDayOfWeek' - integer expression expected testEnum2.mq5 24 16
Is enum type integer or not?