Debugging

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.

 

Stepping Through a Script

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.

 

Debug Mode

The MP Editor has a debug mode that you can enable. Debug mode provides several benefits for testing:

 

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.

 

Diagnostic Tools

MPStepTimeLog.csv

The time each step in an MP takes to process is accumulated and saved in the MPStepTimeLog.csv file. This file is saved automatically in the C:\Analyzer Data folder when you run a script and will report the following values: