If you use for / next loops based on vars, the vars can change and what you expect will happen. When you use vars that have calculations (ex: var - 1), it seems to calculate it the first time through, and then ignore any changes.
Here is a quick example of both cases....
Here is a quick example of both cases....
B4X:
Sub Activity_Create(FirstTime As Boolean)
Dim high As Int = 20
Dim data As List
data.Initialize
Dim count As Int
For count = 0 To 100
data.add(Bit.AND(count,1))
Next
' list size test
Try
For count = 0 To data.Size - 1
If data.Get(count) = 0 Then
data.RemoveAt(count)
count = 0
Continue
End If
Next
Msgbox("Completed dynamic list (calc)","No Bug")
Catch
Msgbox("Failed list size test","Error")
End Try
' dynamic int test
For count = 0 To high - 1
If count = 5 Then high = 10
If count = 15 Then Msgbox("Count too high, failed dynamic int test (calc)","Bug")
Next
' list size test without calc
Try
For count = 1 To data.Size
If data.Get(count - 1) = 0 Then
data.RemoveAt(count - 1)
count = 0
Continue
End If
Next
Msgbox("Completed dynamic list","No Bug")
Catch
Msgbox("Failed list size test","Error")
End Try
' dynamic int test
For count = 0 To high
If count = 5 Then high = 10
If count = 15 Then Msgbox("Count too high, failed dynamic int test","Bug")
Next
End Sub