CallSub (Component As Object, Sub As String) As Object
Calls the given sub. CallSub can be used to call a sub which belongs to a different module.
However the sub will only be called if the other module is not paused. In that case an empty string will be returned.
You can use IsPaused to test whether a module is paused.
This means that one activity cannot call a sub of a different activity. As the other activity will be paused for sure.
CallSub allows an activity to call a service sub or a service to call an activity sub.
Note that it is not possible to call subs of code modules.
CallSub can also be used to call subs in the current module. Pass Me as the component in that case.
Example:
CallSub(Main, "RefreshData")
B4A Class [B4X] CallSubPlus - CallSub with explicit delay - Erel    
Nov 30, 2015   
(26 reactions)In many cases you need to run a task in a few seconds. The solution for such cases is to create a timer and then execute the task in the timer's Tick event. This is good for a single task. However if you need to run multiple tasks then it becomes difficult to maintain.
This small class makes it much simpler. You just need to call CallSubPlus with the target sub and the delay.
Internally it uses a (one shot) timer together with CallSubDelayed or CallSub.
There are four methods:
CallSubPlus...
B4A Code Snippet [XUI][Custom Views] Create Event Name for CallSub - LWGShane    
Dec 22, 2022   
(3 reactions)Just a simple method that makes creating event names for CallSub easier. Useful for Custom Views.
Method:
Private Sub CreateEventName (SubName As String) As String
Return $"${mEventName}_${SubName}"$
End Sub
To use:
CallSub(mCallBack, CreateEventName("YourEvent"))
...
link: Note that in most cases it is better to use CallSubDelayed instead of CallSub....
B4A Question [B4X] Resumable Sub, CustomClass Eventi and CallSub - Star-Dust    
Mar 3, 2021 this
'Call Event
If SubExist(mCallBack,MEvent & "_Event") then
Wait for (CallSub...
link: š„° ...
link: 42 minutes ago:
https://www.b4x.com/android/forum/threads/chiacchiericci.63457/post-804301
but... w...
link: with:
Dim rs As ResumableSub = CallSub(mCallBack,MEvent & "_Event")
Wait for (rs) Complete...
Wish Unlimited number of arguments when using CallSub/CallSubDelayed - LucaMs    
Jul 1, 2019)
I don't know if creating a CallSubDelayed4 (and CallSub4) that allows you to send...
B4i Question Callsub using string-based module name - Jack Cole    
Sep 29, 2019Using b4a, I can call a sub in a different module based on the string name of the module (say CallSub("SomeActivity", "SomeSub"). This is deeply integrated into many of my Android apps. I'm trying to port apps to b4i and discovered that CallSub will not allow the module name to be a string (it is expecting an Object). Is there a way to programmatically call a sub in another module based on the string-based name of the module in b4i?...
B4i Code Snippet CallSub with ANY number of parameters - narek adonts    
Mar 9, 2019   
(1 reaction)Sub CallSubX (Component As Object,SubName As String,Params() As Object)
Dim no As NativeObject=Component
Dim name As String=SubName
Dim ll As List
ll.Initialize2(Params)
For i =0 To Params.Length-1
name=name & ":"
Next
no.GetField("bi").RunMethod("raiseUIEvent:event:params:",Array(Null,name,ll))
End Sub
Example usage
Cal...
Other New feature: CallSub AutoComplete - Erel    
May 24, 2018   
(20 reactions)68252...
B4A Question Callsub from a Service - Declan    
Jun 29, 2022I have a FirebaseMessaging Service that receives data.
I then parse the data
I must now call a Sub i...
link: Solved.
I pass the entire data string to Main - then parse the string....
link: Sub LoadMap(Lat As String, Lon As String, Volts As String, deviceID As String)
pnlMap.Visible = ...
link:
What is the correct syntax?
How can we know? YOUR defined the signature of this sub, not we!
How ...
B4A Question CallSub2 Sub not found - RB Smissaert    
Mar 6, 2022.Keys
Dim oItem As Object = fMap.fShapes.Get(oKey)
If CallSub2(oItem...
'If CallSub2(oItem,"PointInShape", p) Then
m.Put(oKey, oItem)
End If...
link:
Dim tLL As TMapLatLng = PointToLatLng(p)
If CallSub2(oItem, "PointIn_ShapeX...
link:
It is a very big project and I think I have crux of the problem now.
RBS
Eureka!!
agraham was abs...
link:
There is only one solution: send us the project š (use Google translator)
It is a very big proje...
B4J Question java.lang.reflect.InvocationTargetException if to make CallSub2 - peacemaker    
Feb 2, 2022, "meyadisk_RequestUploadPath") Then
CallSub2(Me, "meyadisk_RequestUploadPath", root... this CallSub2 line:
Error occurred on line: 245 (yadisk)
java.lang.reflect.InvocationTargetException....Debug.CallSub4(Debug.java:134)
at anywheresoftware.b4a.debug.Debug.CallSubNew2(Debug.java:81...
link:
CallSubDelayed
Yes, helped, thanks !...
link: I don't understand that code. As you are writing the class you should know whether the sub exists or not and you can call it dire...
Page: 1  
2  
3  
4  
5  
6  
7