I've been trying to do this with all sorts of string literals, but a command is not a string so it doesn't work.
If one could use something like DIM cmd_parameter as (its not a string or int. what is it)
then one could do page&cmd_parameter...
Does b4x have macros
Define p page
pagep
B4X:
***is it possible to do this***
'RXD from Client to Android____________________________________________
Sub AStream_NewData (buffer() As Int)
Select buffer(1)
Case 1
B4XPages.page1.RXD_Data (buffer)
Case 2
B4XPages.page2.RXD_Data (buffer)
Case 3
B4XPages.page3.RXD_Data (buffer)
End Select
***with something like this (which doesn't work)***
'RXD from Client to Android____________________________________________
Sub AStream_NewData (buffer() As Int)
dim n as int
dim Page_n as string
'convert to ascii
n = buffer(2) -48
Page_n = "Page" &chr(n)
B4XPages.Page_n.RXD_Data (buffer)
you might be able to simulate it by putting the pages in a map (that can hold objects), then use the byte to determine which item in map is retrieved, then cast to b4xpage and you should have access to any field in it.
What is the layout/format/protocol of the packets that you are receiving? What is in the first and seconds bytes, and the following bytes?
You are probably about to discover that the _NewData event doesn't always return chunks of data that are whole packets. Sometimes a packet will be spread across multiple received chunks, and sometimes a received chunk will be bytes from different packets (usually the end of one packet and the start of the next packet).