PS: Unfortunately, I can't do something like that, because the first Value1 contains a string and this character (|) may also appear there. And then I'd have the problem with splitting
Type MyValue (Value1 As String, Value2 As String)
'now hover over MyValue and choose "generate create type sub"
Map1.Put("Key", CreateMyValue("Value1", "Value2"))
Type MyValue (Value1 As String, Value2 As String)
'now hover over MyValue and choose "generate create type sub"
Map1.Put("Key", CreateMyValue("Value1", "Value2"))
But you have to be careful!
You must not save the map as a text file, because after reading the content of "map1.Get("Key")" is only pure text.
That means that the code "Dim xvalue As MyValue = map1.Get("Key")" does not work anymore.
Type typPerson(ID As Int, Name As String, Age As Int)
Dim Persons As Map
Persons.Initialize
Dim ID As Int = 4
Dim Person As typPerson = CreatetypPerson(ID, "Erel", 32)
Persons.Put(ID, Person)
Log(Persons.Get(4).As(typPerson).Name)
Public Sub CreatetypPerson (ID As Int, Name As String, Age As Int) As typPerson
Dim t1 As typPerson
t1.Initialize
t1.ID = ID
t1.Name = Name
t1.Age = Age
Return t1
End Sub
But you have to be careful!
You must not save the map as a text file, because after reading the content of "map1.Get("Key")" is only pure text.
That means that the code "Dim xvalue As MyValue = map1.Get("Key")" does not work anymore.
Is it possible to reopen what was saved with this procedure,
B4X:
Public Sub WriteMapAsB4XObject(sDir As String, sFilename As String, mp As Map)
Dim raf As RandomAccessFile
raf.Initialize2(sDir, sFilename, False, True)
raf.WriteB4XObject(mp, raf.CurrentPosition)
raf.Close
End Sub
and read again with this ?
B4X:
Dim m as Map = ser.ConvertBytesToObject(File.ReadBytes(...))
I ask because then I could replace my 4 procedures with a single one.