See the very simple module below. The loop never ends after 10 as shown in the log. It has to be killed with the Debugger. The StartSearch.Show sub is called properly as shown in the log but the loop keeps on going. Why?
Log of the above:
Application_Start
Application_Active
IN StartSearch start
192.168.2.1 connection = false, IPcounter = 1
192.168.2.2 connection = false, IPcounter = 2
192.168.2.3 connection = false, IPcounter = 3
192.168.2.4 connection = false, IPcounter = 4
192.168.2.5 connection = false, IPcounter = 5
192.168.2.6 connection = false, IPcounter = 6
192.168.2.7 connection = false, IPcounter = 7
192.168.2.8 connection = false, IPcounter = 8
192.168.2.9 connection = false, IPcounter = 9
192.168.2.10 connection = false, IPcounter = 10
IN startsearch.show = Main.NavControl.ShowPage('SL')
192.168.2.11 connection = false, IPcounter = 11
IN startsearch.show = Main.NavControl.ShowPage('SL')
192.168.2.12 connection = false, IPcounter = 12
IN startsearch.show = Main.NavControl.ShowPage('SL')
192.168.2.13 connection = false, IPcounter = 13
IN startsearch.show = Main.NavControl.ShowPage('SL')
192.168.2.14 connection = false, IPcounter = 14
IN startsearch.show = Main.NavControl.ShowPage('SL')
192.168.2.15 connection = false, IPcounter = 15
IN startsearch.show = Main.NavControl.ShowPage('SL')
192.168.2.16 connection = false, IPcounter = 16
IN startsearch.show = Main.NavControl.ShowPage('SL')
192.168.2.17 connection = false, IPcounter = 17
IN startsearch.show = Main.NavControl.ShowPage('SL')
192.168.2.18 connection = false, IPcounter = 18
IN startsearch.show = Main.NavControl.ShowPage('SL')
B4X:
Sub doit
socket1.Connect(ipaddress,5500,600)
End Sub
Sub socket1_connected(success As Boolean)
Log(ipaddress & " connection = " & success & ", IPcounter = " & ipcounter)
If success = False Then
ipcounter = ipcounter + 1
ipaddress = ipbase & ipcounter
If ipcounter > 10 Then
socket1.Close
FU.ResignFocus
StartSearch.show
End If
End If
' socket1.Close
doit
End Sub
Log of the above:
Application_Start
Application_Active
IN StartSearch start
192.168.2.1 connection = false, IPcounter = 1
192.168.2.2 connection = false, IPcounter = 2
192.168.2.3 connection = false, IPcounter = 3
192.168.2.4 connection = false, IPcounter = 4
192.168.2.5 connection = false, IPcounter = 5
192.168.2.6 connection = false, IPcounter = 6
192.168.2.7 connection = false, IPcounter = 7
192.168.2.8 connection = false, IPcounter = 8
192.168.2.9 connection = false, IPcounter = 9
192.168.2.10 connection = false, IPcounter = 10
IN startsearch.show = Main.NavControl.ShowPage('SL')
192.168.2.11 connection = false, IPcounter = 11
IN startsearch.show = Main.NavControl.ShowPage('SL')
192.168.2.12 connection = false, IPcounter = 12
IN startsearch.show = Main.NavControl.ShowPage('SL')
192.168.2.13 connection = false, IPcounter = 13
IN startsearch.show = Main.NavControl.ShowPage('SL')
192.168.2.14 connection = false, IPcounter = 14
IN startsearch.show = Main.NavControl.ShowPage('SL')
192.168.2.15 connection = false, IPcounter = 15
IN startsearch.show = Main.NavControl.ShowPage('SL')
192.168.2.16 connection = false, IPcounter = 16
IN startsearch.show = Main.NavControl.ShowPage('SL')
192.168.2.17 connection = false, IPcounter = 17
IN startsearch.show = Main.NavControl.ShowPage('SL')
192.168.2.18 connection = false, IPcounter = 18
IN startsearch.show = Main.NavControl.ShowPage('SL')