Managing Breakpoints
A breakpoint is a marker in an IDL source code file that tells IDL to halt execution temporarily, allowing you to inspect the state of program variables in the program unit where the breakpoint occurred. Breakpoints allow you to control the flow of execution of your IDL program, stopping and starting at will.
Setting Breakpoints in the IDL Workbench
To set a breakpoint in an IDL source code file, place the cursor on the line where you want the breakpoint to appear and doing any of the following:
For more on breakpoints, see Breakpoints.
Using Breakpoints
To explore the IDL Workbench's facilities for managing breakpoints, try the following:
- Open a new IDL Source File.
- Enter the following code:
- Save the file into an existing project using the default name:
breakpoint_test.pro. - Compile the file.
- Run the routine.
Note that the numbers 0 through 50 are printed to the Console view.
Suppose you wanted to stop in the middle of execution and inspect or change the values of the variables. The most effective way to do this is to set a breakpoint at the line where you want IDL to halt execution.
Double click in the grey gutter to the left of the FOR statement in the editor window containing breakpoint_test.pro. A blue dot indicates that a breakpoint has been set:

Now, select Run breakpoint_test from the Run menu (or press F8) to run the breakpoint_test routine. Several things happen:
- Execution stops at the line on which you set the breakpoint.
- The Confirm Perspective Switch dialog appears, asking whether you want to switch to the Debug perspective. (If you have already encountered this dialog and asked IDL to remember your decision, you will not see the dialog again. See Automatic Perspective Switching for details.)
- The Debug view is displayed, whether you switch to the Debug perspective or not.
We will assume in this tutorial that you have switched to the Debug perspective, either automatically or by clicking on the Debug icon in the Perspective toolbar. (If you do not switch to the Debug perspective, you may need to manually expose the Breakpoints and Variables views in the IDL perspective.)
In our example the following views are of interest:
Debug View
The Debug view shows us that we have stopped in the BREAKPOINT_TEST procedure, which was called from the $MAIN$ context.

Breakpoints View
The Breakpoints view shows us all currently defined breakpoints. In our example, there is only one, at line 5 of the BREAKPOINT_TEST routine:

Unchecking the checkbox next to this breakpoint disables the breakpoint without removing it — allowing you to temporarily allow execution to pass by the breakpoint without needing to destroy and recreate it later.
The Skip all breakpoints toolbar button
allows you to temporarily turn off all breakpoint processing with a single click.
Variables View
The Variables view displays the variables in the current execution scope:

In our example, there are only two variables in scope: the index variable i (which has not yet been defined, because the breakpoint halted execution before the first value could be assigned) and the variable multiplier.
Examples
To demonstrate these features, try the following:
- Select Resume from the Run menu or press F8. The program runs to completion, showing its output in the Console view. The Debug view shows that execution is stopped in the $MAIN$ context.
- Select Run breakpoint_test from the Run menu or press F8. Execution stops at the breakpoint again, as expected. Use the Variables view to change the value of the
multipliervariable from 5 to 7, then press F8. The program runs to execution, substituting the new value ofmultiplier. - Unset the breakpoint on at the beginning of the FOR loop by double-clicking on the blue dot. Set a new breakpoint one line down, on the PRINT statement. Now press F8 to run the program and note that the Variables view shows the value of
ito be defined. Press F8 again, and note that execution halts again as the breakpoint (now inside the FOR loop) is encountered a second time. Note that the value of theivariable has been updated. Press F8 again to iterate once more around the loop. Finally, use the uncheck the breakpoint's checkbox in the Breakpoints view and press F8. Notice the routine now runs to completion.