Modify list items


I'm creating an application that needs to modify the elements of a list.
I've made a test program to investigate the situation.

The "for each element..." loop seems to work well when it comes to using the values of each element. (Button 1)

However, when it comes to modifying the elements of the list itself (initializing them with 0, for example: Button 2), nothing happens... As if it were impossible to modify the elements themselves.

Is this normal?


Use the replace list item block


Thank you
So I used the block you suggested in a loop.
It's more complicated, but it works...
In my complete program, I don't have to replace with 0 but I have to use the "Replace all mappings" block. I'll see if I can do it.

Is it normal that using the "for each item" block doesn't work to modify a list itself?

Why do you need items with value 0 in the lisf? You could just delete the complete list, i r set it to create empty list

set global listNum2 to create empty list


In my complete program, I don't have to replace with 0 but I have to use the "Replace all mappings" block.

This is another test program. The purpose is to spell out the letters of a word or short sentence:

1- Build a list containing the characters of the string.
2- Replace each element by what needs to be read.
Examples :
A --> capital a
? --> question mark
é --> "e" acute accent
Replace all mappings" and a dictionary take care of matching.
3- gtts reads the new array: the string is spelled correctly.

However, this other test program doesn't work because it seems impossible for the list elements to be modified by this method.

What about instead of replacing items in a list, creating a new list with the mappings and read the new list?

Btw. it would be great, if you could switch the language to English before taking a screenshot next time


It a good idea :slight_smile:

Here's the same program in English:

That's it, I've succeeded in creating a new list.
In fact, if I understand correctly, "item" is a local variable, which is a copy of the corresponding list[i]. "item" is used to retrieve the value of the browsed list, but not to modify it.

Here's my new code, which will enable me to change the values of the items in my list from term to term.

Thanks again for your help!

Well done!