I created my enum
:
#property script_show_inputs
enum MYENUM
{
first,
second
};
input MYENUM response;
int OnInit()
{
if (response == first)
{
printf("first");
}
if (response == second)
{
printf("second");
}
}
It looks working before init, you can click on drop down and choose value. But when OnInit()
starts it always default "first" value with no matter which was chosen.
How to use enum
with input?
This is where MQL4/5 has a bit of introspection. The variable name for the input
will be replaced (in the input window) by a single line comment following it's declaration, and the same goes for enum fields.
#property script_show_inputs
enum MYENUM
{
first, //First choice
second //Second choice
};
input MYENUM response = first; //Which choice?
int OnInit()
{
if (response == first)
printf("first");
else if (response == second)
printf("second");
}
The input window will read Which choice? | First choice
instead of response | first