如何检查tinyDB标签在App Inventor中是否具有任何属性 [英] How to check if a tinyDB tag has any attributes in App Inventor

查看:283
本文介绍了如何检查tinyDB标签在App Inventor中是否具有任何属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一些有关App Inventor 2中问题的帮助.这种情况是我解析了一个JSON结果,然后将其作为列表(storeparseData)存储在tinyDB标记中.

问题是,我在屏幕启动时就完成了此功能,因此要用该JSON列表填充tinyDB标记,然后根据用户请求搜索特定值.

当应用程序正在运行并且输入搜索条件时,出现以下错误"参数[ empty-string ]是GetValue的参数数量错误" .我想,它找不到任何东西要存储在tinyDB标记中以进行搜索,导致JSON数据需要一些时间来获取和解析.

这是我现在所做的检查存储的列表是否在tinyDB中的操作:

在这里,我检查tinyDB中存储的列表中是否有项目:

那么我如何检查在此标签中是否用JSON结果列表填充了tinyDB,然后可以对其进行搜索? App Inventor 2中有可能吗?

请在可能的情况下为您提供示例代码块或类似的教程(如有)的建议.预先感谢大家的回答.

解决方案

这看起来很奇怪……复杂的if then else结构,空套接字的负载以及您的比较if "storeparsedData" = <empty string>总是错误的……显然没有道理...

您似乎觉得太复杂了? 那呢:

按照我对其他问题的回答中的建议,您应该学习如何使用列表...

还要多做一些教程可能有助于学习更多基础知识...

回答您的问题"您能解释一下为什么选择在此处创建空列表的原因吗?":如果您像示例中那样使用列表,并且尝试读取列表从TinyDB开始,那么如果TinyDB中没有该标记(例如,第一次启动该应用程序之后),那么您还必须考虑应该怎么做.对于列表,在这种情况下,应该返回一个空列表.注意:is list empty?块始终需要一个列表.如果将valueIfTagNotThere设置为空字符串,则会出现运行时错误...

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:

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

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.

解决方案

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:

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

这篇关于如何检查tinyDB标签在App Inventor中是否具有任何属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆