B4J Question Using XUI.SubExists in a Server project

Alessandro71

Well-Known Member
Licensed User
Longtime User
I have many classes that I use in cross-platform app projects that are using XUI.SubExists before calling CallSub.
I'm writing a Server project that will use the same classes.
I know I can't use XUI in a NON-UI project, so all XUI.SubExists are marked as errors.
I also tried to make my own XUI code module which redefines SubExists, but as soon as I type "Public Sub SubExists" the identifier is marked as error because it's a reserved keyword.
Is there any solution to this aside from wrapping each call like this?
B4X:
#if SERVER
if SubEsists(module, subname) ...
#else
if xui.SubEsists(module, subname, params) ...
#end if
 

stevel05

Expert
Licensed User
Longtime User
You can't redefine the method as you said, but you could give it a different name in a code module

Something Like:

B4X:
Public Sub DoesSubExist(Module as Object, SubName as String, Params() as Object) As Boolean
#if SERVER
if SubExists(Module, SubName) Then Return True
#else
if xui.SubExists(Module, SubName, Params) Then Return True
#end if
Return False
End Sub

Not Tested and may need tweaking.
 
Upvote 0

Alessandro71

Well-Known Member
Licensed User
Longtime User
yes, even if it would require modifying all sources with xui.SubExists calls with STUBMODULE.DoesSubExist.
it kinda voids the main purpose of using xui.SubExists (cross-platform source).
 
Upvote 0
Top