Code running before GetValue from Tiny Web Database has finished

Hi,
what mechanism do you use to ensure a GetValue from Tiny Web Database has completed before running the next piece of code?
I have an app that most of the time, on good wifi or mobile data, is running fine but in some circumstances it is trying to get a list index, for example, from a list it should have downloaded from Tiny Web Database. So i'll get a bad argument error due to it not being able to find the item in an empty list indicating it hasn't got the list.
I have tried the obvious things like 'if is empty list then get value again' etc.
I've also tried setting a variable and a label to the got value and running the code only if they are not empty/blank. This does not work either.
An idea I had was to put a value at the end of every list so the code would only run if it had that value but that would mean a massive change to a lot of work and I thought there must be a better way, something I've missed...hope you can help.
Kind regards.

Retrieving data from tinywebDB is a two part process:

  1. You call the data contained in the tag
  2. You handle the data once the data in the tag is returned

Then you do stuff with the data:

image

Put all your blocks that do things with the fetched data in the .GotValue block - after the data has been returned

Thanks.
Is it built into App Inventor that it will not perform any of the next commands until it has the whole value, and will it keep trying to get the Tag value if it's a poor signal i.e. is there a check that it has the whole value?
Thank you.

If it doesn't get the value in the tag, then the .GotValue event will not fire, you cannot test for this inside the .GotValue block, but you may use the webserviceerror block....

image

Ok, thank you. Is it ok to put several, consecutive .GetValue commands in the screen initialisation or should I get them one at a time i.e in the .GotValue event of the last one?

Yes, you should be able to use several getValue commands (you may want to introduce a timer in order to delay the call for each one), but you will need to handle these individually in the gotvalue block

Something like this (not tested):

Thanks for all your help, I'll have a go at reconfigering the initialisation.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.