Array out of range / ArrayResize problem (yes again im sorry)

Back to topics list  | 1 2 To post a new topic, please log in or register
avatar
2017
gooly 2015.12.12 11:18 #
 

The problem is your program logic to resize the array there is something wrong.

Go through your code using the debugger and look always at the size of your arrays when where and how do you change it!

avatar
250
ffoorr 2015.12.12 12:53 #
 

try to print the size of the array

avatar
20
jasonxfield 2015.12.12 13:14 #
 

Solved thanks gooly and ffoorr for your input.

 

My problem was using the ArrayResize variable when setting the Array values without a de-increment -1 to align with Array index sequence. 

 

So I was using this:

ArrayResize(Closed,++closecnt);
Closed[closecnt][0] = "one";

 

When the correct method is:

 

ArrayResize(Closed,++closecnt);
Closed[closecnt-1][0] = "one";
avatar
250
ffoorr 2015.12.12 13:29 #
 
yep that's right
avatar
12985
WHRoeder 2015.12.12 13:32 #
 
This is wrong. You want to increase the size to one and set element zero
    closecnt=closecnt++;
    ArrayResize(Closed,closecnt);
:
    Closed[closecnt][0]="one";
Like this.
//    closecnt=closecnt++;
    ArrayResize(Closed,closecnt+1);
:
    Closed[closecnt][0]="one";
    ++closecnt; // Now you have one.

avatar
20
jasonxfield 2015.12.12 14:59 #
 
Got it thanks WHRoeder :-)
Back to topics list   | 1 2  

To add comments, please log in or register