michaelleewebb
Member
maps do not seem to work the way i expect them too. i use the example below to explain my misunderstanding. i would expect the log output to display both empinfo. but instead the log output looks like this.
Waiting for debugger to connect...
Program started.
(MyMap) {emp1=[IsInitialized=false, LastName=smith, FirstName=john
, Age=20], emp2=[IsInitialized=false, LastName=smith, FirstName=john
, Age=20]}
it seems to me that what i "put" into the map is a pointer to empinfo instead of a copy of empinfo. is that correct ?? how should i go about putting a "copy" of empinfo into the map ??
here's the code
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private xui As XUI
Private Button1 As B4XView
Private MyMap As Map
Type EmpInfos(LastName As String,FirstName As String,Age As Int)
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("Layout1")
MainForm.Show
MyMap.Initialize
Dim empinfo As EmpInfos
empinfo.LastName = "webb"
empinfo.FirstName = "mike"
empinfo.Age = 39
MyMap.Put("emp1",empinfo)
empinfo.LastName = "smith"
empinfo.FirstName = "john"
empinfo.Age = 20
MyMap.Put("emp2",empinfo)
Log(MyMap)
End Sub
Sub Button1_Click
xui.MsgboxAsync("Hello World!", "B4X")
End Sub
Waiting for debugger to connect...
Program started.
(MyMap) {emp1=[IsInitialized=false, LastName=smith, FirstName=john
, Age=20], emp2=[IsInitialized=false, LastName=smith, FirstName=john
, Age=20]}
it seems to me that what i "put" into the map is a pointer to empinfo instead of a copy of empinfo. is that correct ?? how should i go about putting a "copy" of empinfo into the map ??
here's the code
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private xui As XUI
Private Button1 As B4XView
Private MyMap As Map
Type EmpInfos(LastName As String,FirstName As String,Age As Int)
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("Layout1")
MainForm.Show
MyMap.Initialize
Dim empinfo As EmpInfos
empinfo.LastName = "webb"
empinfo.FirstName = "mike"
empinfo.Age = 39
MyMap.Put("emp1",empinfo)
empinfo.LastName = "smith"
empinfo.FirstName = "john"
empinfo.Age = 20
MyMap.Put("emp2",empinfo)
Log(MyMap)
End Sub
Sub Button1_Click
xui.MsgboxAsync("Hello World!", "B4X")
End Sub