Alessandro71 Well-Known Member Licensed User Longtime User Sep 15, 2020 #1 I'm in the process of converting some apps from B4A to B4i I stumbled multiple times in the different SubExist implementation: in B4A it has just 2 arguments, while in B4i it also requires and additional argument as the number of called sub args So the following B4A code B4X: Expand Collapse Copy If (SubExists(callback, "RefreshFPS")) Then CallSub2(callback, "RefreshFPS", 0) End If will become B4X: Expand Collapse Copy #if B4A If (SubExists(callback, "RefreshFPS")) Then #else if B4i If (SubExists(callback, "RefreshFPS", 1)) Then #end if CallSub2(callback, "RefreshFPS", 0) End If this is clearly non elegant and it looks like a candidate for "code smell" is there a better way to handle this? can i skip SubExists at all and just all the function, even if it does not exist, with no side effects?
I'm in the process of converting some apps from B4A to B4i I stumbled multiple times in the different SubExist implementation: in B4A it has just 2 arguments, while in B4i it also requires and additional argument as the number of called sub args So the following B4A code B4X: Expand Collapse Copy If (SubExists(callback, "RefreshFPS")) Then CallSub2(callback, "RefreshFPS", 0) End If will become B4X: Expand Collapse Copy #if B4A If (SubExists(callback, "RefreshFPS")) Then #else if B4i If (SubExists(callback, "RefreshFPS", 1)) Then #end if CallSub2(callback, "RefreshFPS", 0) End If this is clearly non elegant and it looks like a candidate for "code smell" is there a better way to handle this? can i skip SubExists at all and just all the function, even if it does not exist, with no side effects?
Star-Dust Expert Licensed User Longtime User Sep 15, 2020 #2 see here B4A - XUI B4X: Expand Collapse Copy If xui.SubExists(callback, "RefreshFPS", 1) Then ' Your code' CallSub2(callback, "RefreshFPS", 0) End If Upvote 0
see here B4A - XUI B4X: Expand Collapse Copy If xui.SubExists(callback, "RefreshFPS", 1) Then ' Your code' CallSub2(callback, "RefreshFPS", 0) End If
klaus Expert Licensed User Longtime User Sep 15, 2020 #3 Use: B4X: Expand Collapse Copy If xui.SubExists(callback, "RefreshFPS", 1) Then CallSub2(callback, "RefreshFPS", 0) End If Upvote 0
Use: B4X: Expand Collapse Copy If xui.SubExists(callback, "RefreshFPS", 1) Then CallSub2(callback, "RefreshFPS", 0) End If