I need a little help with Type and Arrays, the code below compiles and gives the Log shown.
It looks like the Database never stores the record (Type array)
It looks like the Database never stores the record (Type array)
B4X:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Type DB_Fields (MAC(6) As Byte, RSSI As Int, History(10) As Byte )
Dim DB_Line As DB_Fields
Dim Database(200) As DB_Fields
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("WebServer_Serial")
DB_Line.Initialize
End Sub
Sub Test_Button_Click
Log("Create 10 different records")
For n=0 To 9
DB_Line.MAC = Array As Byte((100+n),101,102,103,104,105)
DB_Line.RSSI = n
DB_Line.History = Array As Byte((100+n),100,100,100,100,100,100,100,100,100)
'DB_Fields=
Log(n & ":MAC=" & BytesToString(DB_Line.MAC, 0, 6, "UTF8") & " RSSI=" & DB_Line.RSSI & " History=" & BytesToString(DB_Line.History, 0, 10, "UTF8"))
Database(n)=DB_Line
'Database(n)=DB_Fields
Next
Log("Show 10 different records")
For n=0 To 9
'Log(n)
DB_Line=Database(n)
Log(n & ":MAC=" & BytesToString(DB_Line.MAC, 0, 6, "UTF8") & " RSSI=" & DB_Line.RSSI & " History=" & BytesToString(DB_Line.History, 0, 10, "UTF8"))
Next
End Sub
'Log shows
'Create 10 different records
'0:MAC=defghi RSSI=0 History=dddddddddd
'1:MAC=eefghi RSSI=1 History=eddddddddd
'2:MAC=fefghi RSSI=2 History=fddddddddd
'3:MAC=gefghi RSSI=3 History=gddddddddd
'4:MAC=hefghi RSSI=4 History=hddddddddd
'5:MAC=iefghi RSSI=5 History=iddddddddd
'6:MAC=jefghi RSSI=6 History=jddddddddd
'7:MAC=kefghi RSSI=7 History=kddddddddd
'8:MAC=lefghi RSSI=8 History=lddddddddd
'9:MAC=mefghi RSSI=9 History=mddddddddd
'Show 10 different records
'0:MAC=mefghi RSSI=9 History=mddddddddd
'1:MAC=mefghi RSSI=9 History=mddddddddd
'2:MAC=mefghi RSSI=9 History=mddddddddd
'3:MAC=mefghi RSSI=9 History=mddddddddd
'4:MAC=mefghi RSSI=9 History=mddddddddd
'5:MAC=mefghi RSSI=9 History=mddddddddd
'6:MAC=mefghi RSSI=9 History=mddddddddd
'7:MAC=mefghi RSSI=9 History=mddddddddd
'8:MAC=mefghi RSSI=9 History=mddddddddd
'9:MAC=mefghi RSSI=9 History=mddddddddd