Bad arguments to select list item

Hello everyone,

I'm hoping someone here can help me solve this problem. I would be very grateful, and you will have great luck this year! :blush:

I encountered the following error message in my app:

Bad arguments to select list item – the operation select list item cannot accept the arguments: , [2], [1]

I believe the issue is somewhere in the section I circled in the picture.

I have three lists: "Motor_A_List", "Motor_B_List", and "Time_List". Since they function the same way, I'll use "Motor_A_List" as an example to explain my question.

I initialized Motor_A_List with all elements set to "0" (as strings). For testing purposes, I set only two elements in the list. In the timer block, I set a for loop from index 1 to num_stage = 2. I don’t think the issue is related to an out-of-range index.

I know that an empty element in the list could cause this error. However, if I didn’t change the content of the textbox, Motor_A_List should remain ["0", "0"], right?
Even when I modified the textbox, I only changed the corresponding list element when textbox ≠ "".

So, I can't understand what is causing the problem.
I would really appreciate any guidance.

Thank you!

Use the companion app and Do it to debug your blocks, see also tip 4 here App Inventor: How to Learn | Pura Vida Apps
see also Live Development, Testing, and Debugging Tools

Taifun


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

1 Like

Please export the project as an aia and post it here.
Your block images don't show the error.

1 Like

Here is the aia file.
Thanks for help.

MCB_H24_v2.aia (209.5 KB)

You were very close.

blocks

And here you went to all that trouble to add "_List" to the variable names of your lists.

So the question here is:

Which list were you intending to check, if any, or should you just eliminate that test by pulling its guts out and hooking them up instead of it?

Draggable replacement:

1 Like

By the way, this is going to cause you problems:

The init value action happens only once at start of screen, and the variable then is no longer associated with the textboxes or labels referenced in its init bock.

So you can't update the background colors or text values from the global variable.

If you want to do that, you instead need to just store the component blocks in the global init lists, and use generic (Any component) blocks to update the selected component.

For just two items per list, you might find it barely worth the trouble.

1 Like

Yeah, the argument issue was resolved after changing num_stage to Time_List. I had checked multiple times but didn’t notice that bug. Sorry for the silly mistake, and many thanks!

I’d also like to follow up on the issue you mentioned.
How can I store the component blocks in the global init lists? I couldn’t find the init list block.

Currently, each list contains only two items for testing, but I plan to extend them to ten items. Is there a more convenient way to change the textbox background color?

For a sample of components in global init lists, search this board for Wordle In a Day

I had successfully changed background color of textbox.
I am really grateful for your help! Thanks a lot.