Sub Process_Globals
'These global variables will be declared once when the application starts.
'Public variables can be accessed from all modules.
Type MyType (ByteVar As Byte)
Private Serial1 As Serial
Private Timer1 As Timer
Public KeyMyType1 As MyType
Public KeyMyType2 As MyType
Public KeyMyType3 As MyType
Public ValueMyType1 As MyType
Public ValueMyType2 As MyType
Public ValueMyType3 As MyType
End Sub
private Sub LogMapContent
Dim i As Int
Dim TempKeyMyType As MyType
Dim TempValueMyType As MyType
Dim TempKeyObjectWrapper As ObjectWrapper
Dim TempValueObjectWrapper As ObjectWrapper
Log("Map Content Size: ", StaticObjectMap.Count)
For i = 0 To (StaticObjectMap.GetNextPos - 1)
If StaticObjectMap.GetAtPos(i, TempKeyObjectWrapper, TempValueObjectWrapper) Then
TempKeyMyType = TempKeyObjectWrapper.EnclosedObject
TempValueMyType = TempValueObjectWrapper.EnclosedObject
Log("Content (Key/Value): ", TempKeyMyType.ByteVar, "/", TempValueMyType.ByteVar)
End If
Next
End Sub
Private Sub AppStart
Serial1.Initialize(115200)
Delay(1000)
Log("AppStart")
' Mark the Objects to make them identifiable
KeyMyType1.ByteVar = 101
KeyMyType2.ByteVar = 102
KeyMyType3.ByteVar = 103
ValueMyType1.ByteVar = 201
ValueMyType2.ByteVar = 202
ValueMyType3.ByteVar = 203
' Initialize the map
StaticObjectMap.Init
' Add 3 element pairs (key/value), the map contains 3
StaticObjectMap.Put(KeyMyType1, ValueMyType1)
StaticObjectMap.Put(KeyMyType2, ValueMyType2)
StaticObjectMap.Put(KeyMyType3, ValueMyType3)
LogMapContent
' Remove the 'middle' element, the map contains 2
StaticObjectMap.Remove(KeyMyType2)
LogMapContent
' Add an already existing element, no change, the map contains 2
StaticObjectMap.Put(KeyMyType3, ValueMyType3)
LogMapContent
' Add the deletes element again (on the top, with another value), the map contains 3
StaticObjectMap.Put(KeyMyType2, ValueMyType3)
LogMapContent
Timer1.Initialize("Timer1_Tick", 3000)
Timer1.Enabled = True
End Sub
Sub Timer1_Tick
LogMapContent
Timer1.Enabled = False
End Sub