Array definition

 
Hi MetaQuotes,

I would like to propose a change to MQL which I hope you will consider.

When defining an array, it is often not possible beforehand to know the number of elements that an Array may require. An example of this would be if you attempt to load a quote file but don't know the number of lines in the file.

In a lot of situations, something similar to the code below would be used:

int numberOfFileLines = <determined by other code>;
string fileLines[numberOfFileLines];

It appears however, that MQL will not tolerate the above code. When an attempt is made to compile the above, the error: " 'numberOfFileLines' - integer number expected" is generated.

I know that it's possible to get around this by creating a much larger array than needed and then using "ArrayResize" to trim it, but it seems a bit of a clumsy way of doing things, as you'd need to know the approximate size of the array before creating it.

Any thoughts?
 
use empty value
string fileLines[];
 
Hi Slawa,

Thanks for your response. I am however, a little confused as to how I could use this. Are you suggesting that I create a blank array first and then use 'arrayResize()' to specify the actual size of the array?

e.g. (using example in previous message)

int numberOfFileLines = <determined by other code>;
string fileLines[];
arrayResize(fileLines, numberOfFileLines);
 
yes. there is right code
 
Thanx for your help!
Reason: