0

I need a little help with an issue in App Inventor 2. The case is that I have a JSON result that is parsed, and then have it stored in a tinyDB tag as a list (storeparseData).

Problem is that, I have this function done as screen initiates, so to have the tinyDB tag populated with that JSON list and then searched for a specific value on user request.

As the app is running and I input a search criteria, I get the following error "The arguments [empty-string] are the wrong number of arguments for GetValue". I suppose that, it finds nothing yet to be stored in the tinyDB tag to search for, cause the JSON data take some time to be fetched and parsed.

Here is what I have done for now for checking if the stored list is in the tinyDB:

enter image description here

Here I check the stored list in tinyDB for an item:

enter image description here

So how can I check if the tinyDB is populated in this tag with the JSON results list, so I can then have it searched? Is this possible in App Inventor 2?

Please someone advise on this issue with a sample code blocks if possible, or a similar tutorial, if there is any. Thank you all in advance for your answers.

CodeBugging
  • 321
  • 12
  • 28

2 Answers2

1

This looks very strange... a complicated if then else structure, loads of empty sockets and your comparison if "storeparsedData" = <empty string> always will be false... obviously this does not make sense...

it looks like you are thinking too complicated? what about this:

enter image description here

As already recommended in my answer to your other question you should learn how to work with lists...

Also doing some more tutorials might help to learn some more basics...

To answer your question "Can you explain why you've chosen to create an empty list there.": if you are working with lists as in the example and you are trying to read a list from TinyDB, then you also have to think about what should happen, if that tag is not available in TinyDB (for example after starting the app the first time). And for lists, in this case an empty list should be returned. Note: the is list empty? block always expects a list. If you set valueIfTagNotThere to an empty string, then you will get a runtime error...

Community
  • 1
  • 1
Taifun
  • 6,165
  • 17
  • 60
  • 188
  • Hi again @Taifun. Sometimes I do think complicated indeed. Meanwhile I've tried a simplified solution as you mentioned but instead of using "create empty list" I had am empty text " ". Can you explain why you've chosen to create an empty list there. The list should be already stored at tinyDB beforehand, shouldn't it? – CodeBugging Jan 10 '16 at 22:16
  • Your solution @Taifun, seems to do the trick of checking tinyDB as being populated or not. But there is a problem. When app starts (first run), tinyDB is empty, so the JSON data have to be fetched, parsed and finally stored at tinyDB. This function takes a while, about 1'35'' or more. I've tried to cope with it, by having a message alert with a button upon screen initiation. Thing is that, smartphone seems as being freeze and a wait or dismiss app error pops up form android OS. How can I deal with this delay in a professional way? Any solution, with a sample blocks if applicable, is welcome. – CodeBugging Jan 10 '16 at 23:06
  • Concerning _why using an empty list?_ see my updated answer. Concerning the other problem: the question is, how do you fetch the json data and how do you prepare the data? You might want to ask a new question for that. – Taifun Jan 11 '16 at 16:10
  • Hi @Taifun, really appreciate your edit. Concerning the json data, are fetched from the site directly, using the parse criteria I need. The results are stored at tag "storeparsedData" in a tinyDB. Is this the most efficient way doing so, or is a better way, like fetching json data in a tinyDB and parse afterwards? Can this be done using blocks like "getWeb.SaveResponce" and how should this block be used? Please advise. – CodeBugging Jan 11 '16 at 22:00
  • as already said, [ask a new question](https://stackoverflow.com/questions/ask)... – Taifun Jan 12 '16 at 15:21
0

You can use Clock function to delay the time. Firstly, just set the global DelayCountdown to specific number in "when Screen1.Initialize" part. Then, by using "when Clock1.Timer" function, you just need to add another check whether the DelayCountdown is equal to zero before you do another function.

enter image description here

zmd94
  • 110
  • 1
  • 8
  • Hi @zmd94. If I get it right, I should use the DelayCountdown clock function to delay the getWeb function? Problem is that as app initiates, user gets in a single screen where input search criteria is met for the app to find in the "storeparsedData" tag at tinyDB. That data should be there when users gets control of app, so how can and what function should be delayed with a timer? – CodeBugging Jan 11 '16 at 22:39