schimanski Well-Known Member Licensed User Longtime User Jun 18, 2011 #1 I get the exception above, after loading a map-file in the following code: Code: Copy Sub ListViewDatenbank_ItemClick (Position As Int, Value As Object) Dim a() As String a= MapDatenbank.Get(Value) <= Exception!!!!!!!!!!! EditText1.Text=Value EditText2.Text=a(0) EditText3.Text=a(1) EditText4.Text=a(2) When I build a map with the following code, it runs without problems: MapDatenbank.Put("Key1", Array As String("A", "B", "C")) MapDatenbank.Put("Key2", Array As String("A", "B", "C")) MapDatenbank.Put("Key3", Array As String("A", "B", "C")) When I save the map with file.writemap and load it again with file.readmap, I get the error-message. How is it possible to read the different values in a string, after loading the map? Thanks for help....
I get the exception above, after loading a map-file in the following code: Code: Copy Sub ListViewDatenbank_ItemClick (Position As Int, Value As Object) Dim a() As String a= MapDatenbank.Get(Value) <= Exception!!!!!!!!!!! EditText1.Text=Value EditText2.Text=a(0) EditText3.Text=a(1) EditText4.Text=a(2) When I build a map with the following code, it runs without problems: MapDatenbank.Put("Key1", Array As String("A", "B", "C")) MapDatenbank.Put("Key2", Array As String("A", "B", "C")) MapDatenbank.Put("Key3", Array As String("A", "B", "C")) When I save the map with file.writemap and load it again with file.readmap, I get the error-message. How is it possible to read the different values in a string, after loading the map? Thanks for help....
agraham Expert Licensed User Longtime User Jun 18, 2011 #2 ReadMap and WriteMap can't cope with arrays. What WriteMap writes is a string that contains the class name of the array and not the contents of the array. What ReadMap returns is that string, not an array. Upvote 0
ReadMap and WriteMap can't cope with arrays. What WriteMap writes is a string that contains the class name of the array and not the contents of the array. What ReadMap returns is that string, not an array.
Erel B4X founder Staff member Licensed User Longtime User Jun 18, 2011 #3 You could use RandomAccessFile.ReadObject / WriteObject instead. These methods can handle arrays and other types. Upvote 0
You could use RandomAccessFile.ReadObject / WriteObject instead. These methods can handle arrays and other types.
P Penko Active Member Licensed User Longtime User Aug 10, 2012 #4 Erel, I had some troubles with WriteMap/ReadMap before I realize maybe it can't handle class objects. Then I found this thread. Because it's not written in the explanation of the function arguments, is RandomAccessFile.WriteObject able to cope with class objects? I have a map which stores two class objects from the class tStyle. Code: Copy Dim obj as tStyle Dim obj2 As tStyle So, I want to save the Map to a file and then restore it. Or, if RandomAccessFile.WriteObject is not capable of that, is there any way to do it? Upvote 0
Erel, I had some troubles with WriteMap/ReadMap before I realize maybe it can't handle class objects. Then I found this thread. Because it's not written in the explanation of the function arguments, is RandomAccessFile.WriteObject able to cope with class objects? I have a map which stores two class objects from the class tStyle. Code: Copy Dim obj as tStyle Dim obj2 As tStyle So, I want to save the Map to a file and then restore it. Or, if RandomAccessFile.WriteObject is not capable of that, is there any way to do it?
Erel B4X founder Staff member Licensed User Longtime User Aug 11, 2012 #5 WriteObject / ReadObject do not support classes. You will need to implement a sub that will save the object to a stream. You can use these methods to save the class variables. Upvote 0
WriteObject / ReadObject do not support classes. You will need to implement a sub that will save the object to a stream. You can use these methods to save the class variables.
P Penko Active Member Licensed User Longtime User Aug 11, 2012 #6 Okay, will try that, thanks. Upvote 0