Download MetaTrader 5
To add comments, please log in or register
Log in to MQL5.community using OpenID. It is convenient!
Brian Kester
794
Brian Kester 2015.11.24 12:50 

I have searched and tried to figure it out for a couple weeks without making a loop and setting each index to zero individually.

Is there a simple way to just clear all the indexes in the 2nd dimension? seems like Arrayinitialize() only clears the first dimension. Thanks.

Demos Stogios
184
Demos Stogios 2015.11.24 16:52  

hello,

i can not directly answer your question, but what is the problem with having a loop? You can also put it in a function to use it easily; if your concern is about speed, i am almost sure, a loop can be as fast in mql code as in assembly (so, it should not matter if you use a ready-made function, or one you are writing your self, speed should be about the same ). But in any way, I assume you do not have to zero your array that frequently so a super speedy function could be even less of a concern :)

best regarsd 

Carl Schreiber
5934
Carl Schreiber 2015.11.24 17:14  
c3po:

I have searched and tried to figure it out for a couple weeks without making a loop and setting each index to zero individually.

Is there a simple way to just clear all the indexes in the 2nd dimension? seems like Arrayinitialize() only clears the first dimension. Thanks.

Just in case that there were a solution for our problem like ArrayMultiDimIni() I guess that this function would lop through all the indices and it might be slower than your way knowing the dimension as this function first has to find out first how many dimension does have the array and what are their sizes.
whroeder1
13596
whroeder1 2015.11.24 17:56  
template <typename Datatype>
void ArrayMultiDimIni(Datatype& a[][], Datatype value){
   int iFirst = ArrayRange(a, 0);
   int iSecond = ArrayRange(a, 1);
   while(iFirst > 0){
      --iFirst;
      for(int iEnd = iSecond; iEnd > 0;) a[iFirst, --iEnd] = value;
}  }
GoS
76
GoS 2015.11.24 18:10  
WHRoeder:
template <typename Datatype>
void ArrayMultiDimIni(Datatype& a[][], Datatype value){...}

Hi WHR,

how do you call that technique of datatyping ? Is there any info about at MQ4-Ref ?

Thanks 

whroeder1
13596
whroeder1 2015.11.24 18:33  
/
To add comments, please log in or register