Syntax Errors
Syntax checking occurs as you enter a line of code but the line is not stored in program memory unless there are no errors when you press Enter or cursor off the line. If a syntax error is detected, the line is color-coded red and an error message is displayed on the message line. You can fix the line then or continue entering lines of code and fix them later.
Run With Errors
By default syntax errors left in code will not allow the program to run. However, you may want to Run With Errors and you can select this option in the Run Environment menu.
Debug Commands
The debug commands described below can all be invoked from either the Debug menu or toolbar, by their shortcut keys, or from a context-sensitive menu revealed by right-clicking in the Edit, Run, or Code Windows.
Navigating to Error Lines
-
Previous Error finds the previous error line.
-
Next Error finds the next error line.
Breakpoints
Breakpoints provide a "pause" in program execution so that variable values and other parameter changes may be observed after whcich you can press Continue.
-
Toggle Breakpoint sets or clears an unconditional breakpoint at the current (cursor) line.
-
Conditional Breakpoint sets a breakpoint at the current (cursor) line based on conditions entered in its dialog box.
-
Global Breakpoint invokes a similar dialog but program execution pauses when the condition is met regardless of where the program is.
-
Clear Breakpoints removes all breakpoints.
-
Run To Cursor quickly sets a temporary breakpoint from the current cursor location.
-
Run From Cursor allows you to start the program from a line other than first line.
Step Functions
-
Step In steps one line of code at a time, following all program branches.
-
Step Over runs the entire sub context and stops at the next executable line of the current context.
-
Step Out continues to end of context, stopping when entering the calling context.
-
STEP (Alt-F1) executes one line of the program, displays the next program line in the message area, and then pauses. If the program is not currently paused, the first press of this key causes the program to be prerun. If no prerun errors are detected the first program line is displayed in the message area. The
next press of the STEP key executes the first program line, then displays the next program line in the message area and pauses.
TRACE
TRACE statements are placed inside your program rather than being invoked as menu/button commands. TRACE displays running program details on the message line and pauses program execution before executing a specific program line. The trace output displays the program line before it is executed and any modified simple variables or array elements and their new values. If a full array is modified then only the array name is displayed. Trace output is also sent to the PRINTALL IS device if PRINTALL is enabled. Tracing slows program execution.
-
TRACE ALL enables tracing of the entire program or a range of program lines..
-
TRACE OFF turns off all tracing.
-
TRACE PAUSE line pauses program execution before the specified program
line is executed. If no line number or label is specified, the program pauses before the next program line is executed and the current
TRACE PAUSE line is deactivated.
Examples:
TRACE ALL 1000,1200 ! turns tracing on from line 1000 to line 1200
TRACE PAUSE 250 ! pauses the program before line 250 is executed
View Debug Windows
There are six Debug Windows for monitoring variables, subroutines, breakpoints and source code as it executes. To choose which windows you want to view, open the Debug Windows dialog box from the View menu. Debug windows are initially docked at the left of the main window but they can be moved and resized as needed. Double-click on a title bar to return to a previous docked position. Debug windows may be docked to the application, to each other, or remain as floating windows.
You can customize the contents of each window by right clicking in it to bring up a context-sensitive menu.
The Watch Window shows changes in values of user-defined variables during each step of program execution.
Select Add Watch Variable from the Debug menu option to add variables to the Watch Window. Watch variable names can be changed by double-clicking on the name. Watch variable values may be changed by clicking on the value. To remove a variable, select the variable in the Watch Window, then select Remove Watch Variable or Remove All Watch Variables.
The Line Breakpoints Window shows the line breakpoint settings as the program is run. You can also add or highlight a breakpoint to enable, disable or remove it from the right-click menu.
The Global Breakpoints Window shows the global breakpoint settings as the program is running. You can also add or highlight a breakpoint to enable, disable or remove it from the right-click menu.
The CALL Stack Window shows subroutines as they are called.
The Code Window shows the program source code and allows you to modify breakpoints during execution.
The Trace Window shows which commands are being executed in a running program (unlike the TRACE statement that only shows one line at a time in the message line before scrolling away). You can clear the Trace Window from the right-click menu.
Cross-Reference Listings
XREF (Cross-Reference) generates a cross-reference list of program entities. Select XREF from the View menu to open the XREF dialog box