List error: Attempt to get item number 1 of a list of length 0

I am passing parameters as list to another screen. If I am checking whether "get start value" is a list then I get TRUE. If I check length of "get start value" then again I get correct answer. Even same if I try to copy "get start value" to another list. However, when I try to access the elements then I get a RUNTIME ERROR that, " Select list item: Attempt to get item number 1 of a list of length 0: []
Note: You will not see another error reported for 5 seconds."

Screen 1:

Screen 2:

I don't understand when there are values and I am able to fetch those then why this error is popping up.

for your tests always start in Screen1 and
use Do it to debug your blocks, see also tip 4 here https://puravidaapps.com/learn.php
see also Live Development, Testing, and Debugging Tools
Taifun


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

Somewhere you are starting your profile screen with less than 1 list element in its start value, and your test (attached) does not catch that before trying to select item 1 (not there.)

Thanks for the response.
First IF is just to copy the passing parameter to another list and see any difference. So that is purely for testing purpose.
In second IF, >= is covered under ELSE case. If the condition is not true then that should go to ELSE case.
Lastly, like I said, if I am trying to print the length of list I am getting it as 2 because I am passing two values in the list and also index 1 is giving me correct value. But I am getting annoyed with the error popping up every time, I reach to this screen.
I have checked the blocks on the screen, and I am not using "get start value" anywhere else. Do you need another part of the code to check?

I tried to disable the IF loops during screen initialization then this error was gone, so it is this block which is creating issue.

Here it is in its simplest form
SCREEN1
image
SCREEN2
image

take your blocks back to this, get it working, then build from there.

If you are going to select item 1, you must guard that test with a test if length of list >= 1.
Read that test as length of list greater than or equal to 1.
The test you had was "less than or equal to 1", which lets through the error case length of list = 0 which does not stop you from selecting item 1 from a list of length 0.

2 Likes

Thanks guys for your valuable help. I manage to solve by using this method. I don't know what difference it made but I actually got rid of error :slightly_smiling_face:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.