Android Question [SOLVED] Call to another SUB

vbmundo

Well-Known Member
Licensed User
Hi,

I see calls to other routines or subs is not in real time, ie when the line of code finds a CallSub should immediately move the pointer execution to the desired routine and then return to the next instruction of the call.

It's what all programming languages does.

I'm running the debugger and I see that after a CallSubDelayed control code stay in the calling routine follow and run after the so-called instructions, long before running the routine call.

It's simply..

  • How can I use Functions in Services that starts when were called
  • How can I use Functions with more than 2 parameters.... CallSubDelayed2 , CallSubDelayed3 ?
Regards
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Don't confuse CallSubDelayed and CallSub. CallSub called the method immediately. CallSubDelayed sends a message to the message queue which calls the sub when the message is processed.
Using CallSubDelayed to interact between activities and services


How can I use Functions with more than 2 parameters.... CallSubDelayed2 , CallSubDelayed3 ?
Pass an array or Map as one of the parameters.

B4X:
CallSub2(MyService, "MySub", CreateMap("X": 100, "Y": 200))

...
Sub MySub(args As Map)
 Dim x As Int = args.Get("X")
End Sub
 
Upvote 0

vbmundo

Well-Known Member
Licensed User

Thanks Erel,

But I need to use Callsub to interact between Activities and Services... NOT CallSubDelayed..

I need to run inmediately, because the rest of execution dependes of Services results.

I'm using DonMamfred MySQL Lib, and he recomend to me that every Routines need to be in a Service... I have all in the Activity and work fine... but as Best Practice, I could migrate all main code to a Service.. but this idea still does not convince me at all

I need each command is executed sequentially, not everything can be asynchronous

But I want to learn to use the best way B4A

Thanks Erel
 
Upvote 0

vbmundo

Well-Known Member
Licensed User

How can I start all Services by code in Main code ?

Regards
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…