'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Type DecoderSettings ( _
Name As String, _
IPAddress As String, _
Port As String)
Dim Decoders As DecoderSettings
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim rac As RandomAccessFile
Dim Map1 As Map
End Sub
Sub Activity_Create(FirstTime As Boolean)
Decoders.Initialize
Map1.Initialize
InsertAndSaveSettings
ReadSettings
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub InsertAndSaveSettings
'INSERT AND SAVE SOME DATA (1st time)
Decoders.Name="Decoder1"
Decoders.IPAddress="192.168.1.1"
Decoders.Port="80"
Map1.Put(Decoders.Name,Decoders)
For i = 0 To Map1.Size -1
Log(Map1.GetKeyAt(i) & " - " & Map1.GetValueAt(i))
Next
'LOG is: Decoder1 - [IPAddress=192.168.1.1, Port=80, Name=Decoder1, IsInitialized=true]
rac.Initialize(File.DirInternal,"settings.dat",False)
rac.WriteObject(Map1,True,rac.CurrentPosition)
rac.Close
'INSERT SOME MORE DATA AND SAVE (2nd time)
Decoders.Name="Decoder2"
Decoders.IPAddress="192.168.1.2"
Decoders.Port="8888"
Map1.Put(Decoders.Name,Decoders)
For i = 0 To Map1.Size -1
Log(Map1.GetKeyAt(i) & " - " & Map1.GetValueAt(i))
Next
'LOG Is: Decoder1 - [IPAddress=192.168.1.2, Port=8888, Name=Decoder2, IsInitialized=True]
' Decoder2 - [IPAddress=192.168.1.2, Port=8888, Name=Decoder2, IsInitialized=True]
' where the Keys are different from eachother but the values are the same. Seems like it
' saving only the data inserted the second time
rac.Initialize(File.DirInternal,"settings.dat",False)
rac.WriteObject(Map1,True,rac.CurrentPosition)
rac.Close
End Sub
Sub ReadSettings
'LET US READ THE DATA WHICH WAS SAVED
rac.Initialize(File.DirInternal,"settings.dat",False)
Dim map2 As Map
map2.Initialize
map2=rac.ReadObject(rac.CurrentPosition)
For i = 0 To map2.Size -1
Log(map2.GetKeyAt(i) & " - " & map2.GetValueAt(i))
Next
'LOG Is: Decoder1 - [IPAddress=192.168.1.2, Port=8888, Name=Decoder2, IsInitialized=True]
' Decoder2 - [IPAddress=192.168.1.2, Port=8888, Name=Decoder2, IsInitialized=True]
' where the Keys are different from eachother but the values are the same. Seems like it
' saving only the data inserted the second time
'
'??????? - I expected more data in "settings.dat" since I have run this example many times
rac.Close
End Sub