Select list item: Attempt to get item number 241 of a list of length 5: [241, 383, 298, 346, 81]

Good afternoon everyone. I'm a 101% newbie to programming, so my questions are probably pretty basic for you. Still, I want to ask for your help.
I am trying to create a random question screen from a list in csv. This screen is created from another that selects them in sequential order, from the first row onwards, and that works correctly.
My problem is that when it comes time to load the first random question that I am programming now, I get this error message:
I understand that the app correctly reaches the list of random questions that I am interested in answering. I give the button "start" and then "next", and here, instead of looking for the first of the questions in the temporary file and putting the corresponding options, put the first number of the list of questions in the question label random and, in the two answer options, the numbers 2 and 3 of that same list. When I click on one of the two, it tells me that the correct answer is number 4 on the list.
I know there is a point where the blocks go to the wrong place, but I have already told you that I am a total newbie at this and I do not know where the error is or how to fix it, and I am convinced that it is something very simple.
Here is the full block programming.

If you are able to help me, I will be more than grateful.

First, try replacing "while test" in Cargar_Archivo, with "if/then"....

On the "File1.GotText" event, try to replace "list from csv table text :: get global elegidos" with "list from csv table :: get text"

Since the error message says you are trying to get item number 305, that means you are confusing the index in a list with a value that might be stored in that list.

Double check how you are feeding your select list item blocks.

GuiM_Haes, I tried your solution, but the app picks the first item from UnaDeDos, csv, not the first item from the random list

Also should you be using the csv data "elegidos" instead of the list "preguntas" ?


@Simon_Casas, at the "index" slot of "select list item" you are giving the input of the number which you would like to retrieve from the list, instead of the index at which the number is present.

Alaqmar_Bohori, I understand. Then, how should I tell the block how to set the row from "preguntas.csv" instead the number from the list?

I keep trying, and I see that the problem is:
When I create "preguntas.csv" the only information is the number of the row in the "UnaDeDos.csv" file. I understand that I should put one more block to pick the full information in the selected row and save it to "preguntas.csv". And here is where I can't continue.
Suggestions are very very gratefully welcome

use Do it to debug your blocks, see also tip 4 here
see also Live Development, Testing, and Debugging Tools

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

Oh, i think you need to pick it from random.

Hey guys!!! I tried some changes, and now I'm almost done. The complete block definition is this:

The app does everything properly until this point:

On the emulator, when I click "Cargar preguntas" the app loads the 5 questions and answers such as this:


It means that the code selects the random questions as I want. But, when I click "Siguiente pregunta" this is what I get:
And the Emulator says

Select list item: Attempt to get item number 2 of a list of length 1: ["preguntas_elegidas.csv"]

So: I've been able to load 5 random questions and save them into a file, but I can't solve how to set them one by one to play.

Any suggestion? Thanks a lot

I think you have to use listview and make the block like this :

I tried it, but I got no improvement.
The fact is that "preguntas_elegidas.csv" is created with only 1 row instead of 5 (or whatever I choose). Should I try to pick random items without creating a new list for them?

Thanks a lot

Try This :

I tried it too, but still nothing new.

Please Share your project, so i can research it.

Thank you

Here is the full block project

And here the .aia file

UnaDeDos_Prueba1.aia (89.4 KB)

Thanks a lot!!!

You're welcome :grin: :+1: