Android Question How to use CallSubX

Scantech

Well-Known Member
Licensed User
How do i call "one" and "two" sub with CallSubX from Ultimate ListView Library


B4X:
Sub one(test As String)
    Log("one")
End Sub
Sub two(test As String, test2 As String)
    Log("two")
End Sub
 

Scantech

Well-Known Member
Licensed User
Is this normal?

*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Unexpected event (missing RaiseSynchronousEvents): two
Check the unfiltered logs for the full stack trace.
** Activity (main) Resume **
one
two
B4X:
cse.CallSubX(Starter, "two", Array("one", "two"))
B4X:
Sub two(test As String, test2 As String)
    Log(test)
    Log(test2)
End Sub
Unexpected envent? It did not crash but has an error?
 

Scantech

Well-Known Member
Licensed User
What is the difference between CallSubX and CallSub? The number of parameters? I wouldn't use it for this. The compiler treats CallSub in a special way.

If you need to pass more than two parameters then pass them as an array or a custom type.
Do you have an example how to pass array of strings and int with Callsub or using Type? i tried to pass an array but says signature does not match. I tried Type and i know im not doing it properly.
 
Last edited:

Scantech

Well-Known Member
Licensed User
is this correct way to pass as type?

'This is at Service
B4X:
    Type Multi(DataReceived As String, Index As Int, l As List)
   
    Public Test1 As Multi
B4X:
Sub Test
    Test1.DataReceived = "DKAJFKLDJ"
    Test1.Index = 5
    Test1.l.Initialize
    Test1.l.Add("HLLLLLLLLLLLLLLL")
   
    CallSub2(Main, "ProcessOBDDataSelfTestMessage", Test1)
   
End Sub
'This is at Main
B4X:
Sub ProcessOBDDataSelfTestMessage(T As Multi)
    Log(T.DataReceived)
    Log(T.Index)
    Log(T.l.Get(0))
End Sub
 
Top