When you run code in the Script Editor you are in fact running it inside a debugger.
This allows you to run code line by line or in chunks, and evaluate the values of your script variables in the watch list as you go.
By default – after a first install – the debugger always runs scripts from the top – the very first line. Just as would happen if you run the script some other way. From top to bottom.
But when you are debugging a script you often want to run a select number of lines or start debugging from a different line. So, to do this, you can disable “Run From Top”. This option is under the Tools menu.
When “Run From Top” is disabled the macro will start from whichever is the current line – i.e. whichever line currently has the cursor on it.
Recently in the forums two different people have had seemingly strange issues with scripts which turned out simply to be because they had this option turned off and weren’t running from the top. In both cases they were getting errors because some variables they were referencing hadn’t yet been created! The script had been started from a point after the variables were set.
So, when running in the editor, if you’ve previously disabled “Run From Top”, and you want to run the script as normal, either reset this option or put the cursor on the first line before running.
And if you see some seemingly strange behaviour which goes away when you run the script outside of the editor – it’s probably just because you haven’t run the script from the top!
For more info on how to use the debugger please see:
http://help.mjtnet.com/article/7-using-the-debugger
http://help.mjtnet.com/article/42-using-macro-schedulers-debugger-to-aid-script-creation