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

I’m in the process of designing a literature quiz App, I am in the final steps thanks to all the help I have received here. My quiz has 20 questions each with three possible answers; time allowed to answer is 20 seconds before the next question appears automatically, if 5 questions are incorrectly answered the game ends though only 10 questions are used per game. So far the questions keep repeating each time the game is played so I still have to solve how to randomly display them and removing them from the list. My main problem now is a message appearing randomly either during the first iteration of the quiz or during any iteration. This message tells me “Select list item: Attempt to get item number 0 of the list”, though the list involved has 60 items in it. I have analyzed my blocks, searched examples in the Forum, done tutorials but I can’t figure out why this is happening. Any advice is greatly appreciated.

Here are my blocks

Hello Alberto - that’s not a random message. It will pop-up anytime your code attempts to access a non-existent item in a List. Since Lists start at 1, item 0 (zero) can never exist.

We can’t see all of your code but, for example, the Global var “RandomIndex” is used as a List Item index and it is initialized as 0 (zero). So, any variable to do with List Items/Indexes should be initialized with 1. That should get you out of the current problem.

1 Like

Hi, thank you very much!!!

Hello Chris, I’ve followed your advice by initializing all Global variables dealing with list/indexes to 1 though I still keep getting the “Select list item: Attempt to get item number 0 of the list” message when dealing with “biography” list, sometimes the App runs fine, sometimes the message pops-up right during the first iteration, sometimes during at a different time, do you have any ideas as to what I’m doing wrong?

Here is an updated view of my blocks:

Hi Alberto
A lot of the code is collapsed so we can’t read it (it’s rather difficult to follow anyway). You have a number of Lists that are used to produce a randomized number - correct? Ensure none of those Lists could result in a zero.

I can’t find the biography List :upside_down_face:

Thank you, I’ll look into it! :slight_smile:

Thank you for all your help, I have tried to make my blocks more organized and have added comments to the most important ones hopefully this will help explain the logic in a clearer way. My quiz is based on Taifun’s example at https://puravidaapps.com/quiz.php. As mentioned before my quiz has 20 questions each with three possible answers; time allowed to answer is 20 seconds before the next question appears automatically, if 5 questions are incorrectly answered the game ends.

I am trying to show the questions on a random basis instead that on a sequential basis. Every time I think I am closer to the completion of the quiz something else comes up, this time the issue is that when the answers are not answered during the 20 second span another one comes up automatically but with the related answer options (buttons) incorrectly assigned, in other words they do not correspond to the question.

When answering the questions correctly before time is out all the text for the related answer options (buttons) corresponds to the proper answer options.

Do you have any suggestions as how solve this issue?

in procedure runQ you additionally have to delete the corresponding answers to the question, which was selected
that was not necessary in the original quiz example, because the questions have been asked sequentially there...


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

Thank you very much for your help, I have learned a great deal with your help, I’m almost done with the quiz, just one more issue I have to fix! :smiley:

I am almost done with my quiz, everything is working fine thanks to all the advice I’ve had here, the tutorials and my own experimenting. There is just one final issue, when choosing a wrong answer sometimes I get the message “ Select list item: Attempt to get item number 0 of the list ” when addressing the “ semblanzas ” variable connected to authorBiography.text . I can’ figure out why it pops-up. I have followed the advice indicating that all variables to do with List Items/Indexes should be initialized with 1. The issue lies in the block where the wrong answer is handled. The index I use to display the authorBiography.Text and the imgAuthor.Picture is generated from the button clicked when answering the question.

What strikes me is the randomly appearing error message indicating that the logic tried to get item number 0 of the list semblanzas since the index that originates when selecting an answer is always different from 0. This error sometimes appears during the first iteration, sometimes during the third and sometimes it does not appear at all and the app runs just fine.

I have here traced the flow of the logic beginning from the user clicking an answer and storing the value in the local variable yourAnswer indicated by the letter A , then that value is used to find the index of yourAnswer in the autores list storing it in another local variable index indicated by the letter B, then finally using that index value in the semblanzas and imagenes lists indicated by the letter C. I would greatly appreciate if you can give some advice as to what is causing this erratic behavior.

let me recommend you to keep all those lists in sync, i.e. if you delete a question from the question list, then also delete the corresponding answers form the answer list, the corresponding image from the imagelist, the corresponding author from the authors list etc. and always use the randomIndex to access the current data in all those lists, no need to have another index variable


Hi, thanks for your response. I have kept all my lists in sync, erasing the question, answer and poem once they have been displayed. I tried to keep all the other lists in sync as well, though since the images, authors, links, and biographies data is needed as wrong answer options appear in two or more questions deleting this data shifts everything around.

I have managed to reduce the “ Select list item: Attempt to get item number 0 of the list ” message from appearing too often by increasing the number of questions, previously I had a list of 20 questions and currently I have 25, also I moved the “set global index to 1” from its previous position to a new one as shown in the image, since I’m not an experienced programmer I’m just assuming that the sequence of blocks has something to do with this issue. Hopefully my experience can help others down the road; meanwhile I’ll keep adding questions trying to reduce the frequency of this issue.

if some data is needed for more questions, you have to copy that data... important is to keep the lists in sync, so a specific index from the question list results in the corresponding answers from the answers list, the corresponding image form the image list, the corresponding author from the authors list, the corresponding link from the links list and the corresponding biography from the biographies list


1 Like

Hi, I have kept all the lists in sync and I copied all the lists with the copy list list block and have placed them inside the logic of the wrong answer, also I have reloaded all the lists with the reset procedure as shown in the image and I’m still getting the same random message “Select list item: Attempt to get item number 0 of the list”, I don’t know if the placement of the lists is still causing this issue though I have tried different placements but still can’t solve the issue. Could you please tell me if the way I am handling the sync process is wrong?

Alberto, could you upload your Project file (.aia) for a Power User to study? I can’t promise that any of us will be quickly available but someone will get down to it when possible.

when exactly do you get that error message? after asking several messages?
and what is the exact error message? which list are you trying to read?

also let me recommend to continue with questions only, if the question list still has items...
you can use the length of list block for that...

if length of list listQ > 1 then...

Thank you very much, I greatly appreciate your help!! The issue happens randomly when dealing with the wrong answer block. When I tried to synchronize the lists everything got shifted around. This file without the sync works just fine though as mentioned the issue happens randomly.literatureQuiz.aia (2.0 MB)

The message appears sometimes when choosing the first wrong answer, sometimes during the fourth or third and sometimes does not appear at all and the quiz runs till the completion of the 10 questions. What puzzles me is the message appearing sometimes during the first question when nothing has been dealt with, no previous question has been answered, no button has been clicked except for the first question. The message always refers to the semblanzas (biographies) list, I can’t post the whole list as it contains 90 biographies and each is several paragraphs long. After the message disappears the app keeps running but the questions and answers do not match, if you keep trying to play the quiz the message keeps appearing. This issue never happens when the right answer is selected it only happens when choosing a wrong answer. The global iterationCounter variable is set as <11 so when the 10th question is reached its answer is displayed, and when the player hits the SIGUIENTE (NEXT) button the final results page is displayed. I really appreciate your effort and help to solve this problem, the support I’ve received is great, this is my first app and I have reached so far thanks to the Forum help but this is overpowering me

it seems to be, the version of your screenshot and your aia file are different...
why do you have 2 lists of each category, for example semblanzas and semblanzas2?

duplicating code, in this case duplicating all lists is never a good idea, see also

why is the copy list block necessary after a wrong answer has been given? you like to continue with the list without removing any item, don't you?

as already suggested, replace this with
if length of list listQ > 1 then...


Hi, I forgot to delete the duplicates for autores, images, links and semblanzas, they are not needed anymore; the only duplicates needed are listQ2, listA2 and poemas2. As it was recommended to keep the lists in sync I should delete the selected item in the right answer logic from all the lists and when dealing with the wrong answer block those deleted items should be copied because they are needed in the logic which I did using a copy list list, also since these items were deleted it was necessary to reload every list during a reset.

I noticed though that doing this everything shifted around and the app did not work as it was doing it previously, that’s why I reverted back to the initial block arrangement, the file I sent is the one working fine except for the issue mentioned.

The reason I’m using this block


is because during each game I only want to display 10 random questions out of the 30 questions included in the list listQ, when the player starts over again only another 10 random questions will be displayed, if I use the if length of list listQ > 1 it would display all 30 questions until the list gets emptied is that right?`