In the following code from here, can someone please explain to me why b needs to be an array (as opposed to a single boolean), and b(1) set as true at the end of the two subs?
b(1) doesn't appear to be actually used anywhere?
b(1) doesn't appear to be actually used anywhere?
B4X:
'usage
ReadData(5000)
Wait For DataReceived (Success As Boolean, Data() As Byte)
Sub ReadData (Timeout As Int)
Dim b() As Boolean = Array As Boolean(False)
TimeOutImpl(Timeout, b)
Wait For Astream_NewData(Data() As Byte)
If b(0) = false Then CallSubDelayed3(Me, "DataReceived", True, Data)
b(1) = true
End Sub
Sub TimeOutImpl(Duration As Int, b() As Boolean)
Sleep(Duration)
If b(0) = false Then CallSubDelayed3(Me, "DataReceived", False, Null)
b(1) = true
End Sub