Array out of range

Back to topics list To post a new topic, please log in or register
avatar
3
Baldus 2015.08.17 21:26
 
          
           double BARS[][24];
           
           void OnStart()

           int size_bars = ArrayRange(BARS,0);
          
           Print(size_bars);  //prints 0
           
           int size_bars_new = ArrayResize(BARS,size_bars+1);
           
           Print(size_bars_new);  //prints 24
          
           Print(TimeHour(time1)); //prints 22
           
           BARS[size_bars_new-1][TimeHour(time1)]= bars ; //gives out of range error
           }  


Hi guys, what am I missing here?  The docs say ArrayResize sizes the first dimension yet I get this error. Any pointers as to where I go wrong are appreciated. Thanks!

avatar
Moderator
3416
GumRai 2015.08.18 00:36 #
 
           
           int size_bars_new = ArrayResize(BARS,size_bars+1);

= 24 elements, 1st dimension is 1

           
           BARS[size_bars_new-1][TimeHour(time1)]= bars ; //gives out of range error

 

 You are trying to access element 23 of the 1st dimension. The 1st dimension only contains 1 element

Back to topics list  

To add comments, please log in or register