initializing an array with variable length?

 

Hey guys,

 Brand new to MQL4, been reading the docs and all that, so go easy on me!

 Just wondering if its possible to initialize an array with a variable length.

 

For instance, the following works fine:

 

double blah[10];

 

...Whereas this doesn't':

 

int arrayLength = 10;

double blah[arrayLength];

 

..returning: "integer number expected".

 

It seems to me that it should be trivial for MQL to support inheriting an array length via an integer variable, so I'm not sure why this behavior is present?

 

Kind regards,

Seb 

 
double blah[];
int arrayLength = 10;
ArrayResize(blah,arrayLength);
ArrayResize() is the only solution for MT4.
 

Ahh I see, thankyou kolier. Your answer is much appreciated!

 

Cheers,

Seb 

 
All arrays in MQL4 are static, hence they can only be initialized with a constant.
 

a compromise might be

#define mysize 10
   double arr[mysize];
Reason: