iOS Question Callbacks with IOS

davemorris

Active Member
Licensed User
Hi, Guys

How do you handle Callbacks in IOS - I am converting code from B4A to B4I

The B4A code is
B4X:
' Timeout trips - hide the progress dialog and raise a Timeout event.
Sub tmrProgressTimeout_Tick()
    Log("Timeout tripped")
    Hide
#if B4A
    If SubExists(mCallback, mEvent & "_Timeout") Then
        CallSub(mCallback, mEvent & "_Timeout")
    End If
#else
    'TODO <<< Put the B4I callback here!
#End If

End Sub
Any ideas?

Kind regards
Dave
 

Brandsum

Well-Known Member
Licensed User
your callback code will also work in b4i. so there is no need to check whether the ide is b4a or not
B4X:
' Timeout trips - hide the progress dialog and raise a Timeout event.
Sub tmrProgressTimeout_Tick()
    Log("Timeout tripped")
    Hide

    If SubExists(mCallback, mEvent & "_Timeout") Then
        CallSub(mCallback, mEvent & "_Timeout")
    End If

End Sub
 

davemorris

Active Member
Licensed User
Hi Brandsum

Thanks, I am sorry I should of tried that before I asked the question - Just got it into my head the a different OS would need a different callback system.

Regards
Dave
 

klaus

Expert
Licensed User
For B4i, you need to use this code:
B4X:
' Timeout trips - hide the progress dialog and raise a Timeout event.
Sub tmrProgressTimeout_Tick()
    Log("Timeout tripped")
    Hide

    If xui.SubExists(mCallback, mEvent & "_Timeout", 0) Then
        CallSub(mCallback, mEvent & "_Timeout")
    End If

End Sub
The SubExist method in B4i needs a 3 third parameter, NumberOfArguments.
This implemented in the xui.SubExists method, compatible for all three products.
 

davemorris

Active Member
Licensed User
Hi, Klaus
Thanks for the input - yes that does appear to work.
For the benefit of someone reading this post (and is not familiar with B4X) then to use xui.SubExists() you will need to insert in Process_Global (or in my case the Class_Global) Sub as shown below, and remember to tick XUI (or iXUI if using B4I) in the library manager.
B4X:
Sub Class_Globals
    Private xui As XUI
Kind regards
Dave
 
Top