I have problems with the connection events (ESP8266WIFI) and I try to identify the problems. Now I have isolated one issue that makes trouble in my code:
When comparing objects, the result of the comparison should be the same, independently at which part of the code I do this comparion, as long as I leave the content of the variables alone. But in b4r it's not! The result of the comparision of the same variables is different between code in the main-part and in the event-part (here Timer, but in connection event of ESP8266WIFI still the same).
Here is the result and my code, you see the problem at comparision 4-5:
a) Why is the same comparision different in main and event (4-5)?
b) Why is are two uninitialized fields (0-1) equal and two Null-initialzed fields (2-3) not equal?
When comparing objects, the result of the comparison should be the same, independently at which part of the code I do this comparion, as long as I leave the content of the variables alone. But in b4r it's not! The result of the comparision of the same variables is different between code in the main-part and in the event-part (here Timer, but in connection event of ESP8266WIFI still the same).
Here is the result and my code, you see the problem at comparision 4-5:
a) Why is the same comparision different in main and event (4-5)?
b) Why is are two uninitialized fields (0-1) equal and two Null-initialzed fields (2-3) not equal?
B4X:
AppStart 0-1: 1
AppStart 2-3: 0
AppStart 4-5: 1
AppStart 6-7: 1
.
Timer1_Tick 0-1: 1
Timer1_Tick 2-3: 0
Timer1_Tick 4-5: 0
Timer1_Tick 6-7: 1
B4X:
#Region Project Attributes
#AutoFlushLogs: True
#CheckArrayBounds: True
#StackBufferSize: 300
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'Public variables can be accessed from all modules.
Public Serial1 As Serial
Public Timer1 As Timer
Public ObjectArray(8) As Object
Public IntArray(8) As Int
End Sub
Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")
Delay(2000)
ObjectArray(2) = Null
ObjectArray(3) = Null
ObjectArray(4) = IntArray(0)
ObjectArray(5) = IntArray(0)
ObjectArray(6) = ObjectArray(0)
ObjectArray(7) = ObjectArray(0)
Log("AppStart 0-1: ", ObjectArray(0) = ObjectArray(1))
Log("AppStart 2-3: ", ObjectArray(2) = ObjectArray(3))
Log("AppStart 4-5: ", ObjectArray(4) = ObjectArray(5))
Log("AppStart 6-7: ", ObjectArray(6) = ObjectArray(7))
Log(".")
Timer1.Initialize("Timer1_Tick", 1000)
Timer1.Enabled = True
End Sub
private Sub Timer1_Tick
Log("Timer1_Tick 0-1: ", ObjectArray(0) = ObjectArray(1))
Log("Timer1_Tick 2-3: ", ObjectArray(2) = ObjectArray(3))
Log("Timer1_Tick 4-5: ", ObjectArray(4) = ObjectArray(5))
Log("Timer1_Tick 6-7: ", ObjectArray(6) = ObjectArray(7))
Timer1.Enabled = False
End Sub