I have this test program where I'm trying to reach a SUB by passing its name as arg of another an initial SUB (see example below).
I'm using callsub2. Documentation says I have to pass component name (which in my case is Main), but syntax checker says that Main is an undefined variable and, when I code "Main" instead, it ignores the routine to be called and does nothing.
B4X:
Sub Activity_Create(FirstTime As Boolean)
rotina1("rotina2", "Teste1")
rotina1("rotina3", "Teste2")
End Sub
Sub rotina1(proc As String, parm As String)
Log ("rotina1 - parm: " & parm)
CallSub2(main, proc, parm ) ' <== NOT CALLING THE DESIRED SUB ROUTINE
End Sub
Sub rotina2(parm1 As String)
Log("rotina 2 - parm: " & parm1)
End Sub
Sub rotina3(parm1 As String)
Log("rotina 3 - parm: " & parm1)
End Sub
Using Me, don't cause syntax error but still doesn't call rotina2 and rotina3... see log below... I even have a for/next loop to repeat the call 5 times but nothing happens.
B4X:
Sub Activity_Create(FirstTime As Boolean)
For i = 1 To 5
Log("Main try " & i)
rotina1("rotina2", "Teste1")
rotina1("rotina3", "Teste2")
Next
End Sub
Sub rotina1(proc As String, parm As String)
Log (" rotina1 - parm: " & parm)
CallSub2(Me, proc, parm ) ' <== NOT CALLING THE DESIRED SUB ROUTINE
End Sub
Sub rotina2(parm1 As String)
Log(" rotina2 - parm: " & parm1)
End Sub
Sub rotina3(parm1 As String)
Log(" rotina3 - parm: " & parm1)
End Sub