List index behavior

Right, so listviewer starts at 1, do lists start at 1 too, or 0 like in code? Basically however lists are indexed seems to change.

1 Like

Indices in the list should start from 1. But due to an internal error, they can start from 0 in some cases. If your index starts at 0, then let the developers know.

%D0%B8%D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5

thank you for the info. I found a work around that will be helpful to anyone with similar issues. Rather than setting an app variable to an index number, my list is a list of objects so I search my list for any object that contains the item clicked and set an app variable to that object. I can make any changes and insert it back to the list by doing a similar search for the object with properties equal to my current object.

2 Likes

@Michael_Mckenna . Can you create and share a simple example of an app that demonstrates the problem that you are seeing? That will help us diagnose the problem.

As far as we can tell indexing always starts at 1. We have some other bugs, unfortunately, that we think can make it look otherwise, though.

Thanks for your help.

-Mark

2 Likes

I had exactly the same problem with block “in list get # __” , sometimes index started at 1 and sometimes it started with 0, either on android or iOS live app. However it always “corrected” when I re-enter same index numbers starting from 1 (i.e. doing nothing new)

I solved it by replacing with block “get property from object”. Here are my current blocks, I hope it helps.

1 Like

As far as I know I believe that we’ve fixed the problems that led to it appearing that list indexing sometimes started at 0 rather than 1. If you are still seeing this error, please let us know and, if possible, send us a share link to a project which displays the problem.

Please do not use the 'get property of object' block to do list indexing. The fact that that works is an artifact of our particular implementation of Lists that we might change in the future.

-Mark

1 Like

the issue was still happening to me a couple of days ago so apparently it was not completely fixed or my project is weird enough to recreate the problem haha.
I dont have anymore a copy of my project with the old blocks causing the problem, I just have the project with the blocks that I showed on my previous message, idk if that still helps so let me know if you still want to take a look so I can share you my project.

Hey there, as a suggestion from @actech I solved my indexing issue by using “create list from text with delimiter” block

thanks

1 Like

False alarm :frowning: even with the partial solution by @actech, the indexing weird behavior happened again today. Would you like a link to my project so you can take a look?

1 Like

Sure. And can you send me clear instructions on how to demonstrate the problem? Also, will this require any explicit API keys or are you using the defaults?

-Mark

You are right, my method does not eliminate the indexing error, because it uses blocks in which this error is contained. Unfortunately, the indexing error for large projects has not been resolved.

Thanks for your help, I have already sent my project to Mark for him to take a look at the issue.

Hi all, same problem here, my list index sometimes starts with #1 others #0.

it’s a bug or is my code wrong?

When working with a list, protect against the wrong index. If there is an element under the index 0, then enter the correction for the indices. This is a bug that will exist for a very long time or forever.

what type of correction do you suggest?
duplicate the function and shift index by “-1”?

If the index starts with 0, then enter a variable with the value 1 and subtract it when calling the functions for working with the index.

Or you can try so.

or so

%D0%B8%D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5

1 Like

This is getting awkward as the Schrödinger’s cat:

I’ve been having problems with list viewer since 2 minutes ago, when I wrote this post:

if I select the last one (or if there is only 1 item), and ask the app to read the content, it says it’s empty 90% of the time.
Should this seemingly complicate solution fix it?

I’ll try it

But now the app is just working fine. absurd.

Screenshot_2019-07-08%20Thunkable

And firebase list starts from 0 while listviewer from 1

AAAAAND now it’s back to NOT working! :sob:

You are right, in some cases the lists fail and it causes a big headache. Place a Label on the screen to control the beginning of the list index, the index in the ListViewer, and jn Firebase. You need constant monitoring to determine the source of the problem.

Use the detector index 0 as in my example above.

In case this can help you understand the bug;
If I ask the app to show the index (in this case in the alert field), the list works as intended, if after this i set the alert to the text it should display, it still works, I tried to reset the app, the phone, the pc, refresh the page, and it still works as intended, but another listviewer in another screen that showsbasically the same lists, doesn’t work while this one works.

After further testing I found that the lists stop working when you change the code in another screen

Screenshot_2019-07-08%20Thusnkable

I solved with this since in my reference lists all entries are unique (the function is not actually needed):

Screenshot_2019-07-09%20Thunkable

where lista is the list you are picking the item from and oggetto is the item

lista%20soluzioneThunkable

@maxb, Is there any chance that you can post a link to a simple app which demonstrates the problem, along with specific instructions on how to reproduce the bad behavior? That will help us diagnose and fix the issue.

Thanks in advance.

-Mark