array size declarator won't compile

 

Hi everyone,

I was wondering why this array initialization won't compile.

   const int ORDERS = 10;
   int orderTicketArr[ORDERS];

 the error is :  invalid index value

I would like to set 10 to a input variable but I can't even get it to work like this. 

any help would be much appreciated   thanks 

 
what about vectors?  are they allowed in mql4?   I couldn't get those to compile either.
 
bluepharo:

Hi everyone,

I was wondering why this array initialization won't compile.

 the error is :  invalid index value

I would like to set 10 to a input variable but I can't even get it to work like this. 

any help would be much appreciated   thanks 

1) To set the size of a dynamic array with a variable(!) you have to use ArraySize(orderTicketArr,ORDERS)!

2) If you want to set the array size at definition you can use either an integer number like 10:

int orderTicketArr[10];

or by #define:

#define ORDERS 10
...
int orderTicketArr[ORDERS];
 
Ok thanks,  I'll give that a try.
Reason: