Android Question [Solved]A problem about ' xui.SubExists(Component As Object ,Sub as String,NotUsed As int) As Boolean ' in B4A,B4j and B4i

Theera

Expert
Licensed User
Longtime User
Hi all,
I don't understand how shouId code about 'NotUsed' parameter in this as belows
B4X:
   #If B4i
            If xui.SubExists(mCallBack, mEventName & "_ResultCalculated",?) Then  '<== How to code?
                CallSubDelayed2(mCallBack, mEventName & "_ResultCalculated", result)
            End If
   #Else
            If xui.SubExists(mCallBack, mEventName & "_ResultCalculated",?) Then  '<== How to code?
                CallSubDelayed2(mCallBack, mEventName & "_ResultCalculated", result)
            End If
   #End If
 

stevel05

Expert
Licensed User
Longtime User
The value is for the number of parameters the sub expects, but is only used with b4i. If you are not using b4i you can use any valid int for instance 0. It might just be easier and more consistent to put the actual number of parameters even though it does nothing:

B4X:
 #If B4i
            If xui.SubExists(mCallBack, mEventName & "_ResultCalculated",1) Then  'Correct value is required
                CallSubDelayed2(mCallBack, mEventName & "_ResultCalculated", result)
            End If
   #Else
            If xui.SubExists(mCallBack, mEventName & "_ResultCalculated",1) Then  'Value is ignored but must be an int.
                CallSubDelayed2(mCallBack, mEventName & "_ResultCalculated", result)
            End If
   #End If
 
Upvote 0

Theera

Expert
Licensed User
Longtime User
The value is for the number of parameters the sub expects, but is only used with b4i. If you are not using b4i you can use any valid int for instance 0. It might just be easier and more consistent to put the actual number of parameters even though it does nothing:

B4X:
 #If B4i
            If xui.SubExists(mCallBack, mEventName & "_ResultCalculated",1) Then  'Correct value is required
                CallSubDelayed2(mCallBack, mEventName & "_ResultCalculated", result)
            End If
   #Else
            If xui.SubExists(mCallBack, mEventName & "_ResultCalculated",1) Then  'Value is ignored but must be an int.
                CallSubDelayed2(mCallBack, mEventName & "_ResultCalculated", result)
            End If
   #End If
Thank you for your replies. How/Where to count the parameter from?
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Thank you for your replies. How/Where to count the parameter from?
The value is for the number of parameters the sub expects
It's the number of parameters the routine you want to verify exists requires.

In this case, the routine you want to call is ResultCalculated which requires only one parameter, so that number in B4I must be one. In other cases, the routine might require two parameters, for example, and you created that routine, so you know they are two.
 
Upvote 0
Top