Value persistence of script local variables
Posted: Wed Apr 08, 2015 4:05 am
I was under the impression that script local variables were just like handler-local variables, except that they were available to all handlers within the script.
The handler-local ("temporary") variable doesn't retain its value once the handler is finished. If you run the same handler again, the temp variable is reset (to "empty"). I thought it would be the same with script local variable.
Not so. Not only its value persists after a handler is finished, but even after you leave the card and come back to it (e.g., in case of a card script). I tried out a number of variations.
In this way, the script local variable seems to resemble more the global variable (except for the fact that it is only accessible within a script).
This was a surprise.
Regards,
Sri.
The handler-local ("temporary") variable doesn't retain its value once the handler is finished. If you run the same handler again, the temp variable is reset (to "empty"). I thought it would be the same with script local variable.
Not so. Not only its value persists after a handler is finished, but even after you leave the card and come back to it (e.g., in case of a card script). I tried out a number of variations.
In this way, the script local variable seems to resemble more the global variable (except for the fact that it is only accessible within a script).
This was a surprise.
Regards,
Sri.