2
Acrobat JavaScript Tools
Inspect Details Window
Breakpoints
The Breakpoints option in the
Inspect
drop-down list enables you to manage program
breakpoints, which in turn make it possible to inspect the values of local variables once
execution is halted. A breakpoint may be defined so that execution halts at a given line of
code, and conditions may be associated with them (see
Using Conditional Breakpoints).
When a breakpoint is reached, JavaScript execution halts and the debugger displays the
current line of code.
To add a breakpoint, click on the gray strip to the left of the code in the script view, which
should cause a red dot to appear. The lines at which breakpoints are permitted have small
horizontal lines immediately to their left in the gray strip. To remove the breakpoint, click
on the red dot, which should subsequently disappear.
Coding Styles and Breakpoints
Placement of the left curly brace (
{
) in a function definition is a matter of style.
Style 1: Place the left curly brace on the same line as the function name, for example,
function callMe() { // curly brace on same line as function name
var a = 0;
}
Style 2: Place the left curly brace on a separate line, for example
function callMe()
{ // curly brace is on a separate line
var a = 0;
}
If you would like to set a breakpoint at the function heading, use Style 1. Note that the
Acrobat JavaScript debugger does not set a breakpoint at the function heading for Style 2.
It is only possible to set a breakpoint from the line of code containing the left curly brace.
This is illustrated below in
Figure 2.16.
It is possible to set the breakpoint on the line below
the function heading for
callMe()
, and on the line containing the function heading for
testLoop()
. Setting a breakpoint at a function heading causes execution to stop at the
first statement within the function.
F
IGURE
2.16
Setting a Breakpoint at a Function Heading
58
Acrobat JavaScript Scripting Guide