I understand the difference between global and local variables. But why should I not always define a variable as global (if I make sure to use unique names)? Problems of a script not being able to access a memvar solved
because with each variable created and assigned a value, memory must be allocated for it.
When you use the data viewer, you can get a cluttered list of all those variables when you are trying to check only one or two.
And keeping from using the same variable in more than one context at the same time isn't so easy to manage.
All Variables Should Be Global... Or Not. - Soliant Consulting
It's all about life cycle management and being able to take advantage of automatic 'garbage collection' instead of having to manage everything yourself and increasing the chance that you get it wrong and introduce bugs in your code for lack of variable management.
If you are going to pick only one "always" approach to variables: then use $local variables. Learn how to use them and pass them via script params; etc.
OK philmodjunk, wimdecorte and bruce. now i know. thanks.
Retrieving data ...