This forum is in read-only mode now. You may discuss your questions on forums of MQL4.community and MQL5.community
Array definitionBack to topics list |
|
CoenWillemse
2005.01.24 02:18
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? |
|
Slawa
2005.01.24 11:58
use empty value
string fileLines[]; |
|
CoenWillemse
2005.01.25 02:26
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); |
|
Slawa
2005.01.25 11:57
yes. there is right code
|
|
CoenWillemse
2005.01.25 23:38
Thanx for your help!
|
Download MetaTrader 5 (450 Kb, web installer) — a new terminal for financial markets
