Debugging

The following commands are provided as a simple way to log information during macro execution. At the end of a macro’s execution (be it via an error, cancellation, or normal completion) all the logged information is sent to the destination that was set during macro execution.

Debug Type Commands

Debug.setDestination name v1.1

The destination should be one of the following string values:

“none” All information is discarded and never shown.

“new” All information is shown in a new document window.

“clipboard” All information is placed onto the active clipboard.

“prompt” All information is shown in a prompt/dialog after the macro finishes.

By default the destination is “new”.

Debug.hasDestination v1.1

Returns @false if the debug destination is “none”, otherwise returns @true.

Debug.log value v1.1

Outputs the given value as a string to the debug destination. A newline is automatically appended.

Debug.logAttributedText text v1.1

Outputs the given text, preserving its attributes, to the debug destination, followed by a newline.

Debug.setIncludePerl isIncludePerl v1.1

Turns on or off sending Perl’s standard output (STDOUT) to the debugging destination, as set by the setDestination command. If isIncludePerl is a true value, then any text printed by Perl will appear in the destination along with other logged content. By default this is off.

Debug.assert verifyValue, [message] v1.1

If the given value is true then the command does nothing. If the given value is false, stops the macro and displays an error message. You can use this to ensure your macro is operating properly during testing.

Debug.setCodeProfilingEnabled enable v1.3

Controls whether or not code profiling is enabled. By default profiling is never enabled. If profiling is enabled the macro executor will record information on how macro execution time is spent, until profiling is disabled or the macro completes.

If a macro finishes without error, and profiling was enabled at any point during execution, a report document will be created that shows which lines of code required the greatest execution time. The report shows the percent of total macro time spent on each single line of code. This can be helpful to discover ways in which to improve the speed of macros.


Previous Chapter
Perl Examples
<<  index  >>
 
Next Chapter
Superseded Commands