I wanted to make a block similar to the one shown below.

but instead of for each item in a list, for each letter in a word.

I’m wondering how do I not have to change the custom block definition every time the user renames the script variable.
I wanted to make a block similar to the one shown below.

but instead of for each item in a list, for each letter in a word.

I’m wondering how do I not have to change the custom block definition every time the user renames the script variable.
If I renamed the script variable wouldn’t the set variable block throw an error because you changed the name?
Oh Yeah, Thanks! I was confused because I changed the upvar name on the inside at one point and forgot to change the set variable block
When I wrote Computer Science Logo Style, I said that a variable is an association between a name and a value. That’s what I was taught, and it’s what almost all the books (or, these days, web sites) say. To my surprise, when I met some CS professors who specialize in programming languages at a conference, they yelled at me. They said that a variable is an association between a memory location and a value, and that the name by which you refer to a variable isn’t technically part of the variable itself. I said okay, but I really didn’t understand what difference it made, until decades later, when we wanted to be able to program a FOR block in Snap!, and so Jens and I invented upvars. And suddenly I got what they were trying to tell me all those years ago! The upvar is one variable, but it has two different names associated with it, one in the environment of the block itself, and one in the environment in which the block is called. Because it’s one variable, changing its value inside the block is visible to the user of the block (and vice versa, but this is the direction that usually matters).
Ok, that makes sense. Thank you for sharing.