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. Most object or point lists can also be accessed by double clicking on the variable to view the list of items within it at that time.
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.
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:
Step Name - MP step descriptor
Exec(N) - Number of times MP step was executed
Overall(A) - Average total time (msec) per step execution
Overhead(A) - Average overhead time (msec) per step execution (processing windows messages)
Exec(A) - Average time (msec) to execute actual MP step function
Msgs(A) - Average number of messages processed before MP step function execution
Overall(T) - Accumulated total time (sec) over the number of times step was executed
Overhead(T) - Accumulated overhead time (sec) over the number of times step was executed
Exec(T) - Accumulated execution time (sec) over the number of times step was executed
Msgs(T) - Accumulated number of messages processed over the number of times step was executed