Stepping Through the Code

Often, when a problem occurs in your code, it is not immediately apparent where the problem lies. As a result, it might be necessary to stop execution repeatedly to learn exactly where the error occurs and inspect the state of variables. While you could do this by setting many individual breakpoints, it is easier to set a single breakpoint somewhere before the problem occurs and then "step" through the code.

Once execution is halted at a breakpoint, the IDL Workbench provides stepping commands that allow you to move through the code one statement at a time. (Many of the Workbench commands have the same functionality as IDL executive commands, which are available whether or not you are using the Workbench.) The stepping commands are found in the Run menu; they are also available via the toolbar on the Debug view. The commands are:

Resume

Menu

Run  Resume

Debug toolbar

tb_resume.gif

Keyboard

n/a

Executive command

.CONTINUE

Description

Resumes program execution.

Suspend

Menu

Run  Suspend

Debug toolbar

tb_suspend.gif

Keyboard

n/a

Executive command

n/a

Description

Temporarily halts program execution.

Terminate

Menu

Run  Terminate

Debug toolbar

tb_terminate.gif

Keyboard

Ctrl-F2

Executive command

n/a

Description

Terminates program execution, returning to the calling context. This option also issues the following commands:

RETALL 
WIDGET_CONTROL, /RESET 
CLOSE, /FORCE, /ALL 
HEAP_GC 

Step Into

Menu

Run  Step Into

Debug toolbar

tb_stepinto.gif

Keyboard

F5

Executive command

.STEP

Description

Executes the current statement.

If the current statement calls another routine written in IDL code, execution steps "into" the called routine and stops.

Step Over

Menu

Run  Step Over

Debug toolbar

tb_stepover.gif

Keyboard

F6

Executive command

.STEPOVER

Description

Executes the current statement.

If the current statement calls another routine written in IDL code, the entire called routine is executed before execution stops again.

Step Return

Menu

Run  Step Return

Debug toolbar

tb_stepreturn.gif

Keyboard

F7

Executive command

.RETURN

Description

Executes all statements until the end of the current routine. This has the effect of returning to the calling routine.

Skip Next Statement

Menu

Run  Skip

Debug toolbar

tb_skip.gif

Keyboard

Ctrl-Shift-F6

Executive command

.SKIP

Description

Skips the current line of code (does not execute it). This is useful for moving past a program statement that causes an error.

Run to Line

Menu

Run  Run to Line

Debug toolbar

n/a

Keyboard

Ctrl-R

Executive command

n/a

Description

Executes statements up to the statement on which the cursor is positioned in the editor.