Previous Application Programming: Debugging and Error-Handling Next

Stepping Through a Program

Once execution halts at a breakpoint, you can step through the program manually, or continue execution automatically. When stepping through a main program, if the next line calls another IDL procedure or function, you have three options with which to handle execution of the nested program:

Manually Stepping Through Code

Select Step Into from the Run menu (or use the F8 shortcut) to execute line containing the breakpoint and stop on the following line. For example, if you enter broken at the command line, execution stops on line 4. Provide a value for i by entering i=10 at the command line and then select Step Into. This executes line 4 with the new value of i and steps to the next program line.

The Output Log reports:

10  

The current-line pointer advances to the next line in the window containing the file broken.pro. You could continue stepping through the program by choosing Step Into repeatedly (or by entering .STEP at the IDL command prompt).

Continuing Program Execution

You can also continue execution of the program without stepping through the code line by line. Select Run from the Run menu, noting that the Output Log shows that IDL calls broken. Define the variable i in the Command Line. Select Run again. The Output Log now shows that IDL calls .CONTINUE. IDL prints the resulting output to the Output Log window:

10  
20  
30  
40  

Automatically Stepping Through Code

The Trace Execution dialog offers an opportunity to automatically step through the program. Select Trace... from the Run menu. The Trace Execution dialog appears.

Figure 8-2: Trace Execution Dialog (Windows)

Figure 8-2: Trace Execution Dialog (Windows)

Click Go or Run to automatically issue the .STEP command until the END statement is encountered, or click Stop to halt trace execution. Moving the slider in the Trace Execution dialog controls the length of the pauses between step commands. You can also select whether to step into routines, executing successive .STEP commands at each line (Windows only), or to step over routines, issuing successive .STEPOVER commands. For more information, see .STEP and .STEPOVER. Click OK or Dismiss to dismiss the dialog.

  IDL Online Help (March 06, 2007)