Assign variable value to a set of tinydb tags

101 views
Skip to first unread message

Frank O'Nestly

unread,
Aug 8, 2018, 3:54:57 PM8/8/18
to MIT App Inventor Forum

Hi everyone,

I'm stuck in a step. I would like to create a global variable that would have as a value a specific set of previously stored tags. But I don't really know how to do that. TinyDB offers only the .GetTags block but I would like a variable taking the value of a specific set of tags, not all of them. You know ? I hope I'm clear, I've been stuck four a few hours and my eyes are now very small... Is there a combination of blocks that allows searching and distinguishing amongst the tags ?

Thanks in advance !

Pierre

TimAI2

unread,
Aug 8, 2018, 4:28:27 PM8/8/18
to MIT App Inventor Forum
You would be best creating a list variable and storing each "tag" as an item on that list.

That said, how do you know which "tags" you want to save to this list? If by index then you can select from getTags (which is a list). If by specific name then you can simply hard code the list ?

If you want to "search and distinguish" how will you do this? Please provide an example of what you hope to achieve...

Abraham Getzler

unread,
Aug 8, 2018, 4:35:26 PM8/8/18
to MIT App Inventor Forum

Frank O'Nestly

unread,
Aug 9, 2018, 6:29:38 AM8/9/18
to MIT App Inventor Forum
Thanks Abraham, it looks very interesting I will dive into it soon.

Frank O'Nestly

unread,
Aug 9, 2018, 6:52:36 AM8/9/18
to MIT App Inventor Forum
Hi Tim,

Ok I will try doing as you say with the list variable.

Ok here is what I want to do :

The program I'd like to code is simple : it asks me a bunch of simple questions everyday about daily activities (what did I eat, read, physical activity, different feelings and observations, etc.), these values are stored in a global variable which is stored at the end in TinyDB.

But I wanted to add a specific feature to the app : for the question "Did you read?", when I say Yes, I wanted to be able to add the title of, for instance, a book I started reading. The thing is that I need to be able to be fast when I answer to the questions of this app because its purpose is to be used everyday to later compare the data and eventually give feedback (like: "you haven't smoke for 7 days, good job!" or "Stop eating crap, idiot" :-). So I wanted to be able to add a new book and not to have to write it down everyday I answer the questions of my app : when I say Yes to "Did you read?", there is a question "What did you read?" that pops up and refers to a listpicker. This list picker refers to a list that has for only and first item "New". When I click on this item, I have a text box to enter the name of the book. Here is the thing: I'd like the title of the book to be added to the listpicker of the question "What did you read?" in order to be able to simply pick up the title of the book and not to have to write it down again.

The way I did it till now is with two separate TinyDB, one simply called "data" for the values of the different answers (stored with a tag that takes the value of the current date) and one called "dynbooks" for the values of the books encoded. From my very limited knowledge in coding, the difficulty comes from the fact that TDB stores with a unique tag a set of value so I don't know how to get a database of my books that makes the sum of all the books in one tag, which is necessary I think to display them in the listpicker that pops up for the question "What did you read?". But I can easily conceive that there are plenty of mistakes in what I think :-)

I hope I was clear, otherwise I can try to explain better.

Thank you for your time and have a very nice day.

Cheers from Belgium
Pierre
Reply all
Reply to author
Forward
0 new messages