Bad arguments to select list item - the operation select list item cannot accept the arguments:

Hi guys. I am new here. I have this strange problem that I get the error in the title of this post for a for each loop. The variable I use as counter works when I loop through a set lable statement. When I just petition the list I try to go through (global data) directly without the loop, I can access any list in it (it is a list of lists, that is build with data from sqlite db). Just when I use the counter it seems to not recognize the value as a list item. The same happens when I use "for each item in list".

are you sure the variable is a list? how to ? with 'is a list' block ? or just you think it is?

show the data on a label to see what the data is.

check one by one.

Why do you set global data and global count twice each?

The list comes in another list, so I select the first item of the parent list to extract the list where the data are. Does that make sense?

Sorry. So that's the case for the global count. For global data, I forgot to remove it after I tried accessing the list directly at a random index (130). So attached what to me looks like it should work, as I can read the list global data as I use it in the loop, and I can use the loop with the counter without list.

Hi Kevin. I did the 'is a list' and get true (attached). I knew that as I can use 'select list item' on it, as long as I am not in the loop.

make a new global / local variable, not global data.

I tried that as you can see in the first screenshot. It was global though. Will try local.

maybe show us what your data look like? and what you want to get?

It looks like the local variable solved it. I will confirm after further testing. Thanks a lot Kevin! After hours of head against the wall moments, this makes my day : )

:sob: Now I have the same problem one level below. So I have this list in global data that comes from sqlite db. It is a list of lists where the inner list looks like this [default, 39.57128145106525, -7.635200049198133]. Now I try to extract in the loop the latitude and longitude from each of the 3 item lists. Although the local variable seemed to solve the problem for global data, it doesn't seem to work now. Am I doing anything weird? I can't figure it out.

Problem with all lists or particular list? If any one list prints results or not?

You are calling open function and print function in screen initialise itself.. Does this extension have Got text event or not? If not why don't you use one clock to run untill sqlite extension gets value from the db? (Sorry if I am wrong)

It happens only in the loop. If I just try to access the same list and sublist without the loop, it works.

Then make sure the global count print Any number or not? Pls debug that variable or show us what is printed in global data

I already tried to put it in button to see if it had to do with screen one. That didn't work either.

The global count works for the loop if it is not with a list. I can just print out the number...

My doubt is , you have added the items to the global data,then again why do you want to print first item into the same variable? :thinking:

For global count, test with length of the list

tried again with the code in a 'when' block instead of the 'when screen initialize' . Same result

Please handle the list properly . It seems you have not handled it properly

Try to catch the sqlite query into a global list, then print the desired items in different variable

Your prob is , you are printing the query items and selecting desired items and all into the same global variables

1 Like

I made separate variables now but the result is the same.

The data in global data are many. Also I am generating them in sceen one, can that be the problem? As the loop runs longer than the query of a single field, maybe it runs into an inconsistency? But then how could I extract the latitude and longitude dynamically? Ideally I can load it when button is clicked.