lookup tag in tinyDB and add value to list if found

28 views
Skip to first unread message

Patrick Jepsen

unread,
May 12, 2019, 6:08:32 PM5/12/19
to MIT App Inventor Forum
I'm looking to create an app where a user can scan a barcode and add a name to the barcode number/tag and save it in list and in a DB. 

The list is to be viewed and edited later on, but i want to keep the entry in the DB so that the next time they scan the same barcode, it adds the item with the previously defined name the list immediately.
If the barcode is not in the DB it prompts the user for a name to associate with the barcode and saves it all in the DB and adds it to the list. 

How would i go about doing that?

I have sifted through the tutorials and the documentation but have yet to find anything to help me move forward.  

Chris Ward

unread,
May 12, 2019, 7:06:03 PM5/12/19
to MIT App Inventor Forum
Hello Patrick

Are you using a bar code scanner device, and linking that with your App? (Bluetooth, USB, WiFi?)

ABG

unread,
May 12, 2019, 10:55:23 PM5/12/19
to MIT App Inventor Forum
Is the DB an online multi user DB (more work),
or just an offline internal DB (easy)?

TinyDB or CloudDB 
both have blocks to return a list of all tags.

If you use scan codes for tags and names for values, you're all set.

ABG

Patrick Jepsen

unread,
May 13, 2019, 1:38:25 AM5/13/19
to MIT App Inventor Forum
I'm just using the barcode scanner sensor element.

Patrick Jepsen

unread,
May 13, 2019, 1:44:03 AM5/13/19
to MIT App Inventor Forum
How would I go about doing that more specifically?
It's just the internal tinyDB for now.
I figured I would need to use the get tags to return a list of all tags, but I can't seem to figure out how to check if the tag already exists, and if so print it to a list.

It might be the new way of thinking in blocks that are making me think a bit limited.

ABG

unread,
May 13, 2019, 12:59:12 PM5/13/19
to MIT App Inventor Forum
I worked up a little sample, just for names..
I haven't yet had time to test it,
needing to warm up a device for that.
See attached.

ABG

Designer.PNG
scanner_TinyDB.aia
blocks.png

ABG

unread,
May 13, 2019, 1:50:41 PM5/13/19
to MIT App Inventor Forum
My testing determined that my cheap phone's scanner was unworthy of use as a test device.

So to allow the TinyDB part of the app to be tested, I used a Text Box for the scan results,
and worked off that for the (manually typed in by me) scan code.

See attached.

ABG

Designer.PNG
Saved.PNG
Saving.PNG
scanner_TinyDB.aia
blocks.png
Capture.PNG
Reply all
Reply to author
Forward
0 new messages