Attempt to get item number 1 of a list of length 0: () with TinyDB

842 views
Skip to first unread message

brian b

unread,
Jan 7, 2017, 6:20:57 PM1/7/17
to MIT App Inventor Forum

Hello,
I am working on an APP that helps with updating what fishing lures that I contain.  I have written everything to input into the database.  But the the error I am getting is:  
Select list item: Attempt to get item number 1 of a list of length 0: (), and I can't figure out why I am getting this error?

I've attached my code for reference, which calls the list and the index's appropriately.  From what I understand this is the same way that I have my information setup in the tiny db.  When I am done with this I will be displaying the full information on a 3rd page.

Thanks in advance for your help.





screen_1.png
Screen_2.png

Taifun

unread,
Jan 7, 2017, 7:11:12 PM1/7/17
to mitappinv...@googlegroups.com
Select list item: Attempt to get item number 1 of a list of length 0: ()
this error message will be provided from a select list item block

on first run of your app, TinyDB is empty, so the GetTags method will be an empty list and selecting the first item from an empty list results in that error



btw: to use the open another screen method together with "Screen1" is a bad idea...


Taifun

Trying to push the limits of App Inventor! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun. 


brian b

unread,
Jan 7, 2017, 7:21:51 PM1/7/17
to MIT App Inventor Forum
When I get past that first screen and goto the second screen to input data.  I then go back to my first screen to look at it, I still get this error.  Is this because that error message is present all the time once it happens the first time?

Thank you for the link to the php page..I will be fixing that issue as well.


Taifun

unread,
Jan 7, 2017, 7:32:24 PM1/7/17
to MIT App Inventor Forum
you get that error in the Screen1.Initialize event
and that event is called as very first event after starting your app

what about adding an if statement like this

if is list empty TinyDB.GetTags
then do nothing
else get the first tag

after coming back from Screen2, usually the Screen1.Initialize event does not fire anymore...
see the notes here https://puravidaapps.com/manager.php about the limitations of the companion app

Taifun
Reply all
Reply to author
Forward
0 new messages