Android Question Is it possible to return values from event driven subs? (SOLVED)

MaxWaterfall

Member
Licensed User
I want to return a value from an event driven sub.

This value will be added to a variable that will count the number of times a message with important data has been downloaded. I could implement it easily with an "x = x + 1" but I was just wandering if you could do "Return 1" and somehow add that returned value to a variable.

Thanks, Max
 

sorex

Expert
Licensed User
the problem will be how the event is raised.

if you call your own sub in the event you could add a return value to it like

B4X:
sub yourevent
savedfiles=savedfiles+savefile(filename) 'not sure if this would work by you could do it in 2 steps by saving the returned value to a variable first and add it to the counter in the 2nd step.
end sub

sub savefile
save file
if filesave=ok return 1 else return 0
end sub
 

MaxWaterfall

Member
Licensed User
The event being raised is the Pop_DownloadedCompleted not sure if your example would work in that case. (Probably should have given you that information beforehand)
Any other ideas?
 

KMatle

Expert
Licensed User
The sub is called by the event's raiser to "inform" you what happened. It is some kind of a one way communication. For sure you want to know if "everything" was downloaded. So why not use a global var which you can modify (increase) and check in "Pop_DownloadedCompleted". If the last download is completed then do xxxx.
 

MaxWaterfall

Member
Licensed User
That's what I have done, I was just wandering it was possible to do it by returning values but it's more hassle than it's worth.

Thanks, Max :)
 
Top