Download MetaTrader 5
To add comments, please log in or register
Have you developed a profitable strategy? Share it with millions of traders via Signals!
murimons
10
murimons 2016.08.01 20:52 


Hello,

 I'm trying to loop over a 2 dimentional array but I get "invalid array access" when trying to access the second array?

Am I doing it wrong?

 

This is my code. The highlighted code gives the error.

 

Any idea?

 

Thanks! 

 

 void ComputePPRZ(CProjection* &clusters[][], CProjection* &prz[]) {
        for (int i=0; i<ArraySize(clusters); i++) {
                ...
                for (int j=0; ArraySize(clusters[i]); j++) {
                        ...
                }
        }
}
whroeder1
13602
whroeder1 2016.08.02 01:56  
  1. ArraySize "returns the number of elements of a selected array" which means for a 2x3 array you get 6, not the number of either dimension. ArrayRange - Array Functions - MQL4 Reference
  2. clusters[i] is illegal as clusters is a two dimensional array, not an array of arrays.
murimons
10
murimons 2016.08.02 07:26  
WHRoeder:
  1. ArraySize "returns the number of elements of a selected array" which means for a 2x3 array you get 6, not the number of either dimension. ArrayRange - Array Functions - MQL4 Reference
  2. clusters[i] is illegal as clusters is a two dimensional array, not an array of arrays.

Ok, Thanks for your answer!


I can't test it at the moment but would this work?


void ComputePPRZ(CProjection* &clusters[][], CProjection* &prz[]) {
        for (int i=0; i<ArrayDimension(clusters); i++) {
                ...
                for (int j=0; ArrayRange(clusters, i); j++) {
                        ...
                }
        }
}
/
To add comments, please log in or register