A large portion of the time spent writing a script is often spent on debugging—that is, finding any bugs and errors in the script and correcting them so that the script runs flawlessly in an execution environment.
There are several ways to test and evaluate your script’s behavior.
One of the most obvious but still useful techniques for testing a script is to simply step through its evaluation one line at a time. This gives you the opportunity to view the effect of each command as it’s executed—typically, scripts execute too quickly to observe what’s happening.
When a script is loaded into the MP Bar, you can step forward one line at a time by clicking the Next Step button.
In the MP Editor, you can enable debugging mode by clicking the Debug button. When you do this, the Next Step button will appear in the editor window, allowing you to step through the script.
The MP Editor has a debug mode that you can enable. Debug mode provides several benefits for testing:
You can step through a script one line at a time.
Each command’s arguments will display their run-time values, so that as you step through the script you can see the actual run-time values stored with each argument.
The Variables view shows the current value of each variable as you step through the script.
Debug mode shows variable values (left column) and current argument values.
These three items provide most of the tools you need to discover errors in your script. Debug mode only works with a single script. This means that if a subroutine is called, you will not see any changes in the MP Editor window until the subroutine returns and execution continues in the current script. To view values in parent scripts and subroutines as a script executes, use the MP Watcher.
In the editor, click the Debug button. In debug mode, all arguments will become read-only and they will display their current values.
Run the script or step through it using the controls at the top of the window.