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.
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
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?
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.