How to list all tags in a namespace

98 views
Skip to first unread message

Michael Moreau

unread,
Sep 5, 2018, 10:54:03 PM9/5/18
to MIT App Inventor Forum
I am using Tinydb and I want to view all tags under a current namespace. Right now (see pictures attached) It lists the first entry shown multiple times. Another part of my app that uses this information is working perfectly fine by pulling individual tags so I know my saving portion is working correctly.

How do I make a list of all entries with different tags? I have tried many different ways and what is pictured is just my last idea to see if I could get it to work.

This is just for an easy check while I am programming but I will need to use this later on for another portion of my app so I would like to get it straightened out.
Get.JPG
Saving.JPG

Chris Ward

unread,
Sep 6, 2018, 4:42:48 AM9/6/18
to MIT App Inventor Forum
Hello Michael

Well, difficult to advise because your code is a bit mangled and your process flow is not obvious :)

BayCheck.Initialize runs the procedure "procedure" up to 10 times, which apparently means it adds the same data 10 times into list "Global Checks". However, it never gets past one item of data because apparently MakeBay.Click stores a bunch of data under only one tag. We don't know the tag name because it's a value gathered from a TextBox?

Tag name from TextBox entry is dangerous because:
  • It is essentially a variable when it is safer to have constant names for Tags
  • There could be Tag Name duplication, resulting in unintentional data overwrite
  • Designing in this way suggests large data for which TinyDB might not be suited
You cannot name a Procedure "procedure" - that will potentially crash the app. Give it a name that describes it's purpose.
Give Components meaningful names but always retain the component type name e.g. Label_PickedValue_Scn1, Button_CalcTotal_Scn1.

Is your while test is an attempt to delay loading of the ListViews until the procedure has completed?

To help more, we need to know:
  • What your data is
  • Where it comes from
  • How often does it update
  • What you want to do with it


Michael Moreau

unread,
Sep 6, 2018, 5:43:01 AM9/6/18
to MIT App Inventor Forum
Sorry, this was just a quick try to see if it could work. I have a list of entries that refer to a number that is associated to the item. Even though the number is the first index for every entry, I made that number the key as well(starting at 1 and probably up to 30 but that will be done later). I ran that as a test to get the first 10 entries hoping it would count up one for every time it went through the procedure and add it to the bottom of the list. I would prefer to use the namespace as a filter and to list everything saved under that, regardless of the key. The MakeBay.Click is actually a temporary button to return me to the other screen. I should have put that off frame. As for naming, the names I gave the text boxes make sense if you work in theater but I couldn't come up with things that would make sense to a programmer at I understand that's bad practice.

I am not sure why it would save everything 10 times. The run variable should count up one every time it goes through the procedure and it should be adding the entry into the list Checks. Is there anything I can put into the tag place to give me all entries in namespace Bays?

Do I have my concepts right on the TinyDB? I am more familiar with Access databases and a little SQL.

  • The data is saving height and beam types for an arena.
  • The saving screenshot is from the screen that saves the information from text boxes. This seems to work fine because in another screen I pull the record by the key and split the text and it works fine.
  • It only updates when the screen is opened.
  • I want to just show all entries saved under the Bays namespace to error check.
Thank you for the help. I felt like the more information link for TinyDB isn't telling me everything I need to know.

Michael Moreau

unread,
Sep 6, 2018, 5:50:37 AM9/6/18
to MIT App Inventor Forum
I should also add that I made all the entries to have separate tags because the original recalling of the information didn't work. I thought it might only allow one unique tag like a primary key and that it was overwriting it because only the last one entered would show up.

SteveJG

unread,
Sep 6, 2018, 11:27:19 AM9/6/18
to MIT App Inventor Forum
You have multiple issues Michael.

Great you understand Access and SQL, unfortunately for you, the TinyDB is a non sql database, sometimes called a flat database.  If you do not intend to overwrite a tag, make the contents of the tag a List. When you write to a tag, you replace its contents.

The name  'procedure' is a reserved word.  Reserved words should be avoided in variables and Procedures.  

For fun,  create a Button to check what tags are available as a test.  Simply set  Label1.text  to   call Bays.GetTags.  This will provide you a visual indication of what tags are available.  You could also create a global variable myBaysTags set to empty list; then the Tags are in a List you can manipulate.  Knowing that might help you debut your app.

Regards,
Steve

Abraham Getzler

unread,
Sep 6, 2018, 1:18:47 PM9/6/18
to MIT App Inventor Forum
This sample app might help you see how to build up and scan collections of tags
representing multiple tables in TinyDB ...
abg

Michael Moreau

unread,
Sep 6, 2018, 8:10:08 PM9/6/18
to MIT App Inventor Forum
I got it to work. Thank you Steve and Abraham. You two pointed me in the right direction. Using the Get tags on a label was not what I was looking for but will be very helpful. I never considered it. I will study that sample database a little more.
Screenshot_Worked.png
Works.JPG

Abraham Getzler

unread,
Sep 6, 2018, 9:02:05 PM9/6/18
to MIT App Inventor Forum
Beware those text comparisons you do on numerical values.

Did you really want 10 < 2 ?

ABG

Michael Moreau

unread,
Sep 6, 2018, 9:13:31 PM9/6/18
to MIT App Inventor Forum
When I used the comparison(list View) it orders it correctly. It only shows up that way when its put into the label by .GetTags. Since I am the only one who will see this screen when debugging, I don't think it will matter. If I do decide to add that to the portion of the app that users will view, I will probably break apart the text and only pull the first index that contains the number and populate it like that. That should work.

Thanks for the help!
Reply all
Reply to author
Forward
0 new messages