Its much better/easier to use script variables than shared or instance variables as they can be created "on the fly"
However, monitoring their values requires work (print to console - use say block, use own created shared dictionary, insert halts and step thru etc etc)
I think we could do with something easier - not sure what
[dev mode]Monitoring of script variables
Moderator: MSandro
Re: [dev mode]Monitoring of script variables
You're right that you can't make a monitor on a script variable. That's because the variable only exists momentarily, while the script is running.
However, "say" or "print to console" do work -- they capture the value of the script variable at the moment they are executed.
And you're also right the script variables are convenient and useful. I use them often to store the restore of some computation. It not only makes my code shorter, it also make it easier to read because a good variable name tells the reader what that variable is or what it's purpose is. But the fact that they are transient and that you can't create a monitor on them make them a more advanced concept, so they are only available in developer mode.
One other place you can see tha value of script variables is in the debugger. You can add a "halt" block to a script to make the debugger appear, then use the "step" button to go through the code one command at a time. The script variable names are shown in the bottom left pane. Selecting one shows it value.
However, "say" or "print to console" do work -- they capture the value of the script variable at the moment they are executed.
And you're also right the script variables are convenient and useful. I use them often to store the restore of some computation. It not only makes my code shorter, it also make it easier to read because a good variable name tells the reader what that variable is or what it's purpose is. But the fact that they are transient and that you can't create a monitor on them make them a more advanced concept, so they are only available in developer mode.
One other place you can see tha value of script variables is in the debugger. You can add a "halt" block to a script to make the debugger appear, then use the "step" button to go through the code one command at a time. The script variable names are shown in the bottom left pane. Selecting one shows it value.
Re: [dev mode]Monitoring of script variables
Unfortunately, that's not practical if the script is longer than a screen's worth as debugger goes back to the top of the script everytime we press Step and you spend all your time scrolling up and down and re-selecting any variable you want to monitorOne other place you can see tha value of script variables is in the debugger. You can add a "halt" block to a script to make the debugger appear, then use the "step" button to go through the code one command at a time. The script variable names are shown in the bottom left pane. Selecting one shows it value.
If the debugger didn't move back to the top each time then it could be a workable method
Re: [dev mode]Monitoring of script variables
EUREKA MOMENT
Make a shared var called varMonitor and stick a monitor of it up next to class name
then to monitor a local var (e.g i)
add
set shared varMonitor to i
at appropriate place in the script
:-)
And or course it can all be done while the program is looping away
Make a shared var called varMonitor and stick a monitor of it up next to class name
then to monitor a local var (e.g i)
add
set shared varMonitor to i
at appropriate place in the script
:-)
And or course it can all be done while the program is looping away
Re: [dev mode]Monitoring of script variables
Yep!
In GP, monitors can be put anywhere, not just on the stage. That's useful because often the stage is shrunk down so monitors are not readable. By putting the monitors elsewhere (e.g. along the top bar) you can see what's going on with your variables even when the stage is tiny.
In GP, monitors can be put anywhere, not just on the stage. That's useful because often the stage is shrunk down so monitors are not readable. By putting the monitors elsewhere (e.g. along the top bar) you can see what's going on with your variables even when the stage is tiny.