Working with 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.

Note
While you can set and use breakpoints in command-line mode using the BREAKPOINT routine and various Executive Commands, breakpoints are vastly more useful when working within graphical mode. See Debugging Tools for further information.

To experiment with breakpoints, do the following:

  1. In the IDL Workbench, type
  2. .EDIT broken 
     

    at the IDL command prompt. This loads the file broken.pro into an editor window.

  3. Edit the first program line to read as follows and then save and compile the program:
  4. PRO BROKEN, i  
     

    This allows you to pass a value for i to the program.

  5. Set a breakpoint in broken.pro by placing the cursor in the line that reads:
  6. PRINT, i*2 
     

    and selecting Toggle Breakpoint from the Run menu or simply double-clicking on the line. A blue breakpoint dot appears next to the line.

  7. Now enter the following to execute the program:
  8. BROKEN, 10 
     

    The Console view displays the following:

    10 % Breakpoint at: BROKEN 10

    and a current line indicator arrow stops at the breakpoint.

    Note
    When execution halts, you may see the Confirm Perspective Switch dialog.

  9. Inspect the value of the variable i by typing
  10. PRINT, i 
     

    at the command line, or by hovering the mouse pointer over the variable in the editor window.