I am trying to transfer data from one app to another.
The data is a list containing data in a custom type.
The data is saved in a file using RandomAccessFile.WriteB4XObject.
'xX~Xx' is just a seperator used to parse the data with Regex at the other end
Here is the code that SENDS the data:
Here is the code that READS the data:
the tooltip in B4j says:
One question I have. The B4J app is B4xPages. The type is declared in B4xMainPage not Main. Declaring it in main causes strange errors.
here are the custom data types that are in the lists I am trying to transfer:
The data is only about 100 to 3000 bytes at present and transfers just fine. the issue is when I try to read the data.
The code to read:
I tried:
But it won't compile. "Types do not match" error.
The data looks good when it comes in, but is not in list format it is coming in with each TYPE item that was in the list in brackets-comma delimited.
Am I going to have to pass each list one item at a time?
Thanks for any help.
The data is a list containing data in a custom type.
The data is saved in a file using RandomAccessFile.WriteB4XObject.
'xX~Xx' is just a seperator used to parse the data with Regex at the other end
Here is the code that SENDS the data:
Android Side:
UDPPacket.Initialize(Serializator.ConvertObjectToBytes($"DataFilexX~Xx${Lst.Get(X)}xX~Xx${R.ReadB4XObject(0).As(List)}"$), MasterIPAddress, Packet.Port) 'Generate a new UDP message
UDPSocket.Send(UDPPacket) 'Send confirmation we received information
B4X:
Dim NewMessage As String = Serializator.ConvertBytesToObject(Packet.Data) 'Read the new packets that has been received
Dim LL() As String = Regex.Split("xX~Xx", NewMessage)
StatusLbl.Text = $"${StatusLbl.Text}${CRLF}Receiving: ${LL(1)}"$
Dim R As RandomAccessFile
R.Initialize(File.Combine(File.DirData("SwipeList"), "SyncData"), LL(1), False)
r.WriteB4XObject(LL(2), 0)
One question I have. The B4J app is B4xPages. The type is declared in B4xMainPage not Main. Declaring it in main causes strange errors.
here are the custom data types that are in the lists I am trying to transfer:
B4X:
Type NotePoperties(Txt As String, TxtClr As Int, BClr As Int, Ht As Int, DTme As Long, GUID As String, Idx As Int, FNAR As Double, FName As String, FNFormat As Int)
Type LOLType(Sort As Int, Fname As String, ListName As String, BColor As Long, TextColor As Long, MoveTo As String, Selected As Int)
The code to read:
B4X:
Dim R As RandomAccessFile, It As List, i As Int
R.Initialize(File.Combine(File.DirData("SwipeList"), "SyncData"), "Archive.swl", False)
' R.Initialize(File.DirData("SwipeList"), "Archive.swl", False)
It = R.ReadB4XObject(0)
B4X:
Dim Lst As List = LL(2).As(List)
r.WriteB4XObject(Lst, 0)
The data looks good when it comes in, but is not in list format it is coming in with each TYPE item that was in the list in brackets-comma delimited.
Am I going to have to pass each list one item at a time?
Thanks for any help.