D davemorris Active Member Licensed User Longtime User Aug 9, 2019 #1 Hi, Guys How do you handle Callbacks in IOS - I am converting code from B4A to B4I The B4A code is Code: Copy ' 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
Hi, Guys How do you handle Callbacks in IOS - I am converting code from B4A to B4I The B4A code is Code: Copy ' 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 Aug 9, 2019 #2 your callback code will also work in b4i. so there is no need to check whether the ide is b4a or not Code: Copy ' 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 Upvote 0
your callback code will also work in b4i. so there is no need to check whether the ide is b4a or not Code: Copy ' 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
D davemorris Active Member Licensed User Longtime User Aug 10, 2019 #3 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 Upvote 0
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 Longtime User Aug 10, 2019 #4 For B4i, you need to use this code: Code: Copy ' 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. Upvote 0
For B4i, you need to use this code: Code: Copy ' 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.
D davemorris Active Member Licensed User Longtime User Aug 12, 2019 #5 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. Code: Copy Sub Class_Globals Private xui As XUI Kind regards Dave Upvote 0
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. Code: Copy Sub Class_Globals Private xui As XUI Kind regards Dave