How to locally scope a variable in a screen vs a label?
Posted: Wed Jan 24, 2018 12:55 am
How do I declare a local variable inside a screen block? Say As a general example, say I have something like this:
However, is "name" set in the global space?
Would this lead to issues if I use the same variable name elsewhere in the code? ie,
Basically I'm worried that one block of code containing the same variable name (name in this case) will be overwritten by some other block of code, leading to confusing results.
Is there a way to locally scope the variable within a screen and a label block? Or are they already locally scoped?
Code: Select all
screen my_screen:
for i in mylist:
$ name = mylist[i]["name"] + some_string
if name == "blah":
text "Hello, " + name
elif name == "blah2":
text "Hey, " + name
However, is "name" set in the global space?
Would this lead to issues if I use the same variable name elsewhere in the code? ie,
Code: Select all
screen my_screen:
for i in mylist:
$ name = mylist[i]["name"] + some_string
if name == "blah":
text "Hello, " + name
elif name == "blah2":
text "Hey, " + name
label hello:
$ name = get_name()
call screen my_screen
if name == "buns":
pass
if name == "bums":
pass
e "It's " + name
Is there a way to locally scope the variable within a screen and a label block? Or are they already locally scoped?