Download MetaTrader 5
To add comments, please log in or register
Follow the news. View our company's official channel!
tim
35
tim 2014.12.23 04:17 

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 

tim
35
tim 2014.12.23 08:50  
what about vectors?  are they allowed in mql4?   I couldn't get those to compile either.
Carl Schreiber
5938
Carl Schreiber 2014.12.23 08:57  
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];
tim
35
tim 2014.12.23 22:11  
Ok thanks,  I'll give that a try.
/
To add comments, please log in or register