Type theData (a1 as int, a2 as long, a3 as float, a4 as string) 'etc...
...
dim a as theData
a.initialize
a.a1=100
a.a2=10000000000
a.a3=0.0012
a.a4="my data, your data..."
Dim cx As B4XSerializator
dim b() as byte=cx.ConvertObjectToBytes(a)
I was asking about having a better organization, and not sending so many variables at once. But if it's the best solution, I'll work with only one type, thank you
I was asking about having a better organization, and not sending so many variables at once. But if it's the best solution, I'll work with only one type, thank you
Dim type As data1 (data1Ok As boolean, data1Num As int, data1Value As string)
Dim type As data2 (dataOk As boolean, data2Num As int, data2Value As string)
A
ssuming I have many types and many variables in each type. my question was if more than one type could be serialized. If it is not possible, I will serialize a single type with many variables
You can create a List, add a Map to the list which also explains the type so you know what type is in the Map.
B4X:
dim l as List
l.initialize
Dim m as map
m.initialize
m.Put("Type", "Type1")
m.Put("TypeObject", mytype1object)
l.put(m)
Dim m as map
m.initialize
m.Put("Type", "Type2")
m.Put("TypeObject", mytype2object)
l.put(m)
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.