This forum is in read-only mode now. You may discuss your questions on forums of MQL4.community and MQL5.community
Arrays in build 198 not initialisedBack to topics list |
|
PaulHampton-Smith
2006.11.08 08:29
Hi,
this has uncovered sloppy coding on my part more than anything else. While variables are initialised to zero or "" when declared, the contents of arrays are not. In fact, they (usually?) contain the value stored in the previous execution of start(). At least this is certainly the case with string arrays. I have now written three initialisation routines like this one for string, double and int arrays void InitialiseStringArray(string& arr[]) { for (int i = 0 ; i < ArraySize(arr) ; i++) arr[i] = ""; } and declare arrays like this start() { string strItems[10]; InitialiseStringArray(strItems); // .... } |
|
Zap
2006.11.08 12:09
int ArrayInitialize( double&array[], double value)
Sets all elements of a numeric array to the same value. Returns the count of initialized elements. Note: It is not recommended to initialize index buffers in the custom indicator init() function as such functions are initialized automatically with an "empty value" at allocation and re-allocation of buffers. |
Download MetaTrader 5 (450 Kb, web installer) — a new terminal for financial markets
