Android Question (SOLVED) - Is it possible to return more than 1 value in Resumable Subs?

Myr0n

Active Member
Licensed User
Hi everybody

Is it possible to return moren than 1 value in resumable subs like
B4X:
Dim SenderFilter As Object = sql.ExecQueryAsync("SQL", "SELECT * FROM table1", Null)

Wait For (SenderFilter) SQL_QueryComplete (Success As Boolean, rs As ResultSet) '<=== like 
SQL_QueryComplete
if yes, how can I do it?

Thank you
 

Myr0n

Active Member
Licensed User
Well i would love to know how to implement a method signature to return 2 values or more from a custom method.

Thx
 

Myr0n

Active Member
Licensed User
Put them both into a map and return the map.
As far as i know you can not return multiple values from a sub. Not in a normal way and even not in a resumeable sub.
Is exactly what I am doing, but i was thinking to implement a solution like the jdbcsql library works.

Thx
 

Enrique Gonzalez R

Well-Known Member
Licensed User
yes it is possible. think this:
Wait For (SenderFilter) SQL_QueryComplete (Success As Boolean, rs As ResultSet) '<=== like
as a simple Sub. how do you call a sub then? with Callsub3 and Callsubdelayed3 (better the later)

B4X:
private sub yourSub
wait for yourResumableSub_Complete(args1 as int, args2 as int)

end sub

private sub yourAnotherSub
do something... 
callsubdelayed3(me,"yourResumableSub_complete",args1,args2)
end sub
just watch out i did not test the code.
 

Myr0n

Active Member
Licensed User
yes it is possible. think this:


as a simple Sub. how do you call a sub then? with Callsub3 and Callsubdelayed3 (better the later)

B4X:
private sub yourSub
wait for yourResumableSub_Complete(args1 as int, args2 as int)

end sub

private sub yourAnotherSub
do something...
callsubdelayed3(me,"yourResumableSub_complete",args1,args2)
end sub
just watch out i did not test the code.

I gonna try and i get back to you.

Thx
 

Myr0n

Active Member
Licensed User
Thank you so much for everyone.
 

Erel

Administrator
Staff member
Licensed User
And if you do it like this, you don't even need to use Wait For, surely?
Wait For is needed because we assume that DoSomething is a resumable sub. There is no other reason to use Wait For.

B4X:
Sub DoSomething As ResumableSub
 'Download something
 'wait for result
 Return Array(1, 2, "c")
End Sub
 
Top