Download MetaTrader 5
To add comments, please log in or register
Did you like the article? Share it with your friends!
snailbeard
15
snailbeard 2014.04.13 07:16 

I recently moved a lot of code compiled by build 509 to build 625. Overall 625 found a lot of issues missed by the old compiler, but I'm puzzled by an issue with ArraySize() used on a two dimensional array passed by reference, which still works fine when the updated source is compiled by 509.

I wrote a small test EA to try and isolate the issue and I've already discussed it on several other forums before posting here, in case I was missing something obvious. However, since no one has pointed an error in my code so far perhaps the experts here can shed some light on the issue:

                bool bwaShift2DimArrayOfInt(int& arrData[][], int dim1,int dim2)
                  {
                 
                   Print("Two dimensions: ");
                   int iDim0=ArrayRange(arrData,0);
                   int iDim1=ArrayRange(arrData,1);
                   
                   PrintFormat("ArrayRange: iDim0 = %d, iDim1 = %d \n", iDim0, iDim1);
                     
                   int maxsize=ArraySize(arrData);
                   if( maxsize == 0 )
                   {
                      Print("bwaShift2DimArrayOfInt(): maxsize == 0 ");
                      Print(":   maxsize: ",maxsize,", dim1: ",dim1,", dim2: ",dim2);
                      Print("ERROR ArraySize returned Zero!");
                      forceAppExit();
                      return(false);
                   
                   }
                   else if((dim1*dim2)>maxsize)
                     {
                      Print("bwaShift2DimArrayOfInt(): (dim1 * dim2) > maxsize: ");
                      Print(":   maxsize: ",maxsize,", dim1: ",dim1,", dim2: ",dim2);
                      Print("ERROR Array size is wrong!");
                      forceAppExit();
                      return(false);
                     }
                   else {
                      Print("bwaShift2DimArrayOfInt(): ");
                      Print(":   maxsize: ",maxsize,", dim1: ",dim1,", dim2: ",dim2);
                      Print("SUCCESS ArraySize() returned POSITIVE INT!");
                     }
                 
                   return(true);
                  }

The top level scope ArraySize returns the expected values.

but the output from ArraySize called in the function reports the ArraySize() of the two-dimensional array passed by reference as zero, whereas the one dimensional array passed by reference returns the correct ArraySize.

Files:
/
To add comments, please log in or register