Android Question How to modify a command by inserting an external string

Electrocutioner

Member
Licensed User
Longtime User
Hi All,

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)

Thanks!
 

teddybear

Well-Known Member
Licensed User
There are no macros as you think in b4x, but you can achieve this function using duck typing.
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
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.
 
Upvote 0
Top