Maybe I am missing something obvious but this bug has been doing my head in!
Since I have narrowed it down to between 2 statements, here is my code:
where SetPoint is:
Okay, so the problem is that:
PathPoints(0) is unchanged on the first run of this code (as expected)
but on all subsequent times this part of the code is executed
PathPoints(0) is getting updated to a new value (which is actually PathPoints(1)'s value).
Here is what my log looks like before and after the execution of this statement:
Can anyone spot an obvious mistake, but I do not understand why B4A is updating 2 values from the array?
Thanks!
Since I have narrowed it down to between 2 statements, here is my code:
B4X:
Log ("AddtoPath:" & PathPointIndex & ":" & p.x & "," & P.y & " start:" & PathPoints(0).x & "," & PathPoints(0).y)
PathPointIndex = PathPointIndex + 1
SetPoint(PathPoints(PathPointIndex),P.x,P.y)
Log ("AddtoPath:" & PathPointIndex & ":" & p.x & "," & P.y & " start:" & PathPoints(0).x & "," & PathPoints(0).y)
where SetPoint is:
B4X:
Sub SetPoint(P As PointType,x1 As Int,y1 As Int)
P.x = x1
P.y = y1
End Sub
Okay, so the problem is that:
PathPoints(0) is unchanged on the first run of this code (as expected)
but on all subsequent times this part of the code is executed
PathPoints(0) is getting updated to a new value (which is actually PathPoints(1)'s value).
Here is what my log looks like before and after the execution of this statement:
B4X:
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
AddtoPath:0:395,476 start:373,436
AddtoPath:1:395,476 start:373,436
AddtoPath:0:377,547 start:345,513
AddtoPath:1:377,547 start:377,547
Can anyone spot an obvious mistake, but I do not understand why B4A is updating 2 values from the array?
Thanks!