Select list item: Attempt to get item number 0 of the list ”

Hi there, I’ve encountering a random problem with my app, I’ve been getting the “ Select list item: Attempt to get item number 0 of the list ” on a random basis, in previous posts I’ve received very valuable information and have followed all recommendations, after implementing these solutions the problem seemed to have disappeared though recently it has reappeared. I have initialized all variables having to do with lists items/indexes to 1. What strikes me is the randomly appearing error message indicating that the logic tried to get item number 0 of a list with 90 items. This error sometimes appears during the first iteration, sometimes during any iteration and sometimes it does not appear at all and the app runs just fine. I would greatly appreciate any help.

A picture of relavant blocks is required

H, thanks for your response, the issue pops up in the block where the wrong answer is handled as indicated in the image. The idea behind the game is to answer a question with three different options, when a wrong answer is chosen the index of the selected button text is looked up in a list then passed to a variable named index , then that index is used to look for a value in a list called semblanza (it has 90 items) and in a list called imagenes (it has 90 items) to be displayed in authorBiography.text and in imgAuthor.Picture

Here are my blocks:

What is in the list autores?
Why does it never change?

Autores list is a list that holds all the names of autores (authors), it never changes because its items can be reused in another question. In other words for instance author X, can be shown in question 2 and in question 15 for instance though autores items are only used in the wrong answer block

To further explain the logic behind the App I’m attaching a flow diagram which describes the behavior of the Quiz. This diagram only covers the wrongAnswer logic since that is where the issue arises randomly.

The flow is as follows:

  • A global variable named listYourAnswer is initiated as an empty list
  • A global variable named index is initiated as 1
  • A question with three options is displayed and when a button with the wrong answer is clicked, the value of that button is added to listYourAnswer
  • That value is passed to a local variable called yourAnswer
  • With that value a search is done to find the index of yourAnswer in autores list then the value is stored in a global variable called index
  • With index variable a search is done in semblanzas list and the value is displayed in authorBiography.Text, likewise a search is done in images list and the value is displayed in imgAuthor.Picture
  • When the poetryLink button is clicked a search is done in the links list using the same global variable index

Semblanzas, images and links lists never change since the items are reused because they can appear in several questions. Each list holds hold 90 items and they never get emptied, so that is why I can’t understand when I get the message “ Select list item: Attempt to get item number 0 of the list ” which is always referring to semblanzas list.

Hope this can explain the logic behind the issue.

Could you please send a screenshot of the error


The problem may lie here , global listYourAnswer is empty list , that is linked to the error source if you see

Thank you for your response, listYourAnswer is initiated as an empty list, when it is used in the block it already has a value which is passed on through the click of a button as indicated in step 4 of my previous replay, also the most intriguing for me is its randomness, the problem sometimes never happens and sometimes it happens during the first iteration, sometimes during any other iteration. I’m at a total loss right now since I’ve tried all I can think of.

you have to keep your lists in sync as already mentioned in your other post

Taifun


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

Hi, thanks for your support. When I delete listA, listQ and poemas lists there is no problem as the intention is not to have them displayed again, when I try to keep the lists in sync deleting the images, links, biographies, authors etc. as well everything gets shifted around as the items in those lists are used when answering a wrong question, do you have an idea as to how I can sync my lists without affecting the logic?

see my answer in your other thread
Taifun
PS: I will close this one