B4A Tutorial [B4X] Resumable subs that return values (ResumableSub) - Erel    Aug 25, 2020   (39 reactions) The steps required are:
1. Add As ResumableSub to the resumable sub signature.
2. Call Return with the value you like to return.
3. In the calling sub, call the resumable sub with Wait For (<sub here>) Complete (Result As <matching type>)
Notes & Tips
- If you don't need to return a value but sti B4J Tutorial [B4X] Resumable Subs - Sleep / Wait For - Erel    Feb 22, 2018   (49 reactions) Code Flow
Sub S1
Log("S1: A")
S2
Log("S1: B")
End Sub
Sub S2
Log("S2: A")
Sleep(0)
Log("S2: B")
End Sub
The output is:
S1: A
S2: A
S1: B
S2: B
54883
Whenever Sleep or Wait For are called, the current sub is paused. This is equivalent to calling Return.
Wait for a resumable sub to complete and B4A Question Resumable subs return type must be ResumableSub (or none). - walt61 (first post)    Dec 02, 2023   (1 reaction) The method's signature should be:
Sub getRatings(l As liquorInfo) As ResumableSub
To be on the safe side, I would also change:
' Old code:
rating = result.Get("average_rating")
' New code:
rating = result.Get("average_rating").As(Double)
For more info and examples about ResumableSubs that ret B4A Question B4XPages and ResumableSub - Sagenut (first post)    Dec 31, 2022   (2 reactions) A Resumable Sub MUST end with
as ResumableSub
to return a value.
Then it can be everything, and you must match it correctly with the receiver variable.
Change it and then the code from post #2 should work. B4J Tutorial [B4X] How Resumable Subs work - agraham    Jan 30, 2019   (27 reactions) As the return type of Sum, in this example, is Resumable Sub then we can invoke Sum and assign its return value to a variable of that type. At first sight this looks reasonable, we do this all the time – but in this case Sum will not have completed and have a result, that’s what we will wait for, s B4A Question Resumable Sub that returns 2 values - Sagenut (first post)    Jan 03, 2023   (1 reaction) You could try creating a Type and returning that as the value. B4J Question Return Value from Resumable Sub - Erel (first post)    Dec 08, 2017   (1 reaction) Yes.
1. Note that you can call it like this:
Wait For (Temperature_GetRS) Complete (Result As Double)
2. The problem is in Temperature_Get. It is a resumable sub by itself. So the return type cannot be Double. Just remove it as you are not returning anything anyway. B4A Question Resumable Subs - order of execution - Star-Dust (first post)    May 29, 2021   (6 reactions) 'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize
Wait For (Download1) Complete (result As boolean) 'Resumable Sub1
Wait For (Download2) Complete (result As boolean) 'Resumable Sub2
Wait For (Download3) Complete (result As boolean) 'Resumable B4A Question Resumable subs cant return a value? - stevel05 (first post)    Jul 26, 2017   (1 reaction) The resumable sub returns when it executes the waitfor, the sub is then resumed when the result is received, so there is nowhere to return a result.
I would use callsub to send the process where I wanted when the result is received. B4A Question Resumable sub return type must be resumable sub or none. none - Erel (first post)    May 06, 2020 See the first search result: https://www.b4x./?query=resumable+sub+return Page: 1   2   3   4   5   6   7   Powered by ColBERT |