Scope of local and global variables (fixed now)

Volmark

Member
Can somebody explain to me the scope of local variables? If I define and set the value of the local variable (in macro) can this variable keep the value until the macro is running next time or I have to use the global variables for this purpose? How long the global variables keep their value?
Thanks in advance ...
 

RSF

Well-known member
  • Yes, local variables retain their value after the macro finishes executing, and can be used in subsequent executions, or inspected manually in the macro definition screen
  • My experience is that both types of variables retain values until the variables are manually deleted or cleared (manually or via macro actions) -- even local variables' values are retained across a reboot, at least on my phone.
  • The only difference is in the scope of visibility (and where one needs to go in the app, to see the values)
 

tanutanu

Well-known member
Can somebody explain to me the scope of local variables? If I define and set the value of the local variable (in macro) can this variable keep the value until the macro is running next time or I have to use the global variables for this purpose? How long the global variables keep their value?
Thanks in advance ...
Basically it is same as other languages. The difference is the scope to access and the namespace.
Both of the current values are stored permanently until you delete them, even if your device power off. All variables are initialized by them when MD is starting up. This is different than a typical language.

I recommend you just write and test some tiny macros instead of asking so many things:)
That's the best practice to learn MD(y) I know just reading documents is boring.
 

Volmark

Member
Basically it is same as other languages. The difference is the scope to access and the namespace.
Both of the current values are stored permanently until you delete them, even if your device power off. All variables are initialized by them when MD is starting up. This is different than a typical language.

I recommend you just write and test some tiny macros instead of asking so many things:)
That's the best practice to learn MD(y) I know just reading documents is boring.
I apologize for boring requests. I'm trying to formulate my questions as short and precise as possible. I'm reading the documentation (wiki and forum posts) and experimenting intensively, but sometimes I completely stop because I can't find out some miserable things that are obvious to others. Hope for understanding ...
 

tanutanu

Well-known member
I apologize for boring requests. I'm trying to formulate my questions as short and precise as possible. I'm reading the documentation (wiki and forum posts) and experimenting intensively, but sometimes I completely stop because I can't find out some miserable things that are obvious to others. Hope for understanding ...
I meant reading helps or wiki articles is boring(at least for me;)).
Enjoy trial and error:) Even if not working exactly same as you expected, it would be fun for you(y)
 
Top