tmf Member Licensed User Longtime User Jan 26, 2017 #1 So I have a list dim list1 as list then I add 3 booleans list1.add(false) list1.add(true) list1.add(false) then I save the list File.WriteList(File.DirDefaultExternal, "mylist", list1) then later I read the list list1.clear() list1 = File.ReadList(File.DirDefaultExternal, "mylist") My issue is it seems this list is now of type String and not boolean How do people deal with this?? I searched and found no answers. Richard.
So I have a list dim list1 as list then I add 3 booleans list1.add(false) list1.add(true) list1.add(false) then I save the list File.WriteList(File.DirDefaultExternal, "mylist", list1) then later I read the list list1.clear() list1 = File.ReadList(File.DirDefaultExternal, "mylist") My issue is it seems this list is now of type String and not boolean How do people deal with this?? I searched and found no answers. Richard.
tmf Member Licensed User Longtime User Jan 28, 2017 #21 OK I am getting ultra confused, I read lists and arrays are considered the "same thing" so you can do dim a as list ' list of maybe "I","AM","TESTING" dim b() as string ' and after assignment b(0) = "I" b(1) = "AM" b(2) = "TESTING" b = a Basic4android automatically converts regular arrays to lists. So when a List parameter is expected you can pass an array instead. from https://www.b4x.com/android/help/collections.html and if this *does* work should dim b() be b(3) or will it "autofill" RichardS Upvote 0
OK I am getting ultra confused, I read lists and arrays are considered the "same thing" so you can do dim a as list ' list of maybe "I","AM","TESTING" dim b() as string ' and after assignment b(0) = "I" b(1) = "AM" b(2) = "TESTING" b = a Basic4android automatically converts regular arrays to lists. So when a List parameter is expected you can pass an array instead. from https://www.b4x.com/android/help/collections.html and if this *does* work should dim b() be b(3) or will it "autofill" RichardS
Erel B4X founder Staff member Licensed User Longtime User Jan 29, 2017 #22 I'm not sure that I understand the question. Note that lists and arrays are not considered the same thing. B4A will automatically convert an array to a list when the parameter type is a List. Other conversions will not happen automatically. Save list: Code: Copy Dim raf As RandomAccessFile raf.Initialize(..., ..., False) raf.WriteB4XObject(YourList, 0) raf.Close Load list: Code: Copy Dim raf As RandomAccessFile raf.Initialize(..., ..., False) Dim list As List = raf.ReadB4XObject(0) raf.Close Upvote 0
I'm not sure that I understand the question. Note that lists and arrays are not considered the same thing. B4A will automatically convert an array to a list when the parameter type is a List. Other conversions will not happen automatically. Save list: Code: Copy Dim raf As RandomAccessFile raf.Initialize(..., ..., False) raf.WriteB4XObject(YourList, 0) raf.Close Load list: Code: Copy Dim raf As RandomAccessFile raf.Initialize(..., ..., False) Dim list As List = raf.ReadB4XObject(0) raf.Close