Note: The screen captures in this topic are from a Formula Table. System Formulas are very similar, but do not include the numeric grid.
The built-in AXIS Script Debugger allows you to check the execution of your formulae at run-time. Learn more about VB Script Language here.
To enable the Debugger, go to the System Parameters Dialog ("File"->"Parameters"->"System Parameters..." menu) and check the "Enable debugger for AXIS Script" checkbox (for interactive runs and/or for batch runs) on the "Formula" tab. You also need to define at least one breakpoint at the line you wish to stop. To define a breakpoint or delete an existing breakpoint, edit the formula and go to the "AXIS Script"->"Toggle breakpoint" menu or press F9 key. The breakpoint will be created at the line where your cursor currently is. The line will be marked by a red dot in the selection margin (grey strip at the left edge of the text panel).
Once the breakpoints are created, you can start executing the formula normally (e.g., run a cell). The cell run will be stopped when the execution of the formula reaches the first breakpoint and the Debugger window will open. The next executed statement (current statement) will be indicated by a yellow arrow in the selection margin.
To see the value of a variable, hover the mouse cursor over the variable in the text panel. The current value of the variable will be shown in the tool tip.
Pressing Ctrl+C / clicking
icon will copy the
currently selected text into Clipboard. You cannot edit the text or
the grid during debug.
Pressing F9 key / going to "Breakpoints"->"Toggle
breakpoint" / clicking
icon will toggle breakpoint at the current
line.
Going to "Breakpoints"->"Clear All Breakpoints" / clicking
icon will clear all breakpoints.
Pressing F10 key / going to "Debug"->"Step Over" /
clicking
icon will execute the current statement, move execution
marker to the next line and wait your for next command.
Pressing F11 key / going to "Debug"->"Step Into" /
clicking
icon will move the execution to the first line of a
subroutine or a function called in the current statement. The
debugger will scroll the text panel if necessary to bring this
subroutine or function into view. Only subroutines or functions
defined by you can be debugged this way. If the current statement
contains no calls or calls to AXIS-defined functions or subroutines
only, then this command acts the same as F10 / "Step Over"
command.
Pressing F5 key / going to "Debug"->"Continue" /
clicking
icon will execute the formula until the next breakpoint is
hit or the execution is finished.
The "Close" menu options allow you to terminate execution (the cell run will be terminated with an error), continue execution, ignoring all breakpoints in this formula and continue execution, ignoring all breakpoints in all formulae used in this run.
If you try to close the debugger window or click
icon, you will be
offered the same three options in the following dialog:
Watch Window
The Watch window is located at the bottom of the Debugger window. It is available for running both Formula Tables and System Formula Batches.
You can customize the appearance and size of the Watch window as well as the Script and Grid (for Formula Tables only) windows through Debugger menu "Layout" or by dragging splitter bars with the mouse.
The Watch window is used to evaluate local and/or predefined AXIS variables. You can type variable names in the Variable column or right click anywhere on the window then select Add watch option. If "Add watch (pre-defined variable)" is selected a list of System (Table) Formula variables will appear. Variable values in the Value column would change as you step through the code.
The variable list in the Watch window is saved along with the formula itself so next time when the Debugger window is open, all variables defined in the Watch window during the previous run will be available to you.
TIP
To stop execution at the point when a variable has a particular value, use the following technique:
Let's assume that you have the following code:
Sub Test ()
Dim i As Integer
For i = 1 To 10
<insert the code here>
.....
Next
End Sub
If you want the debugger to stop when i has the value of 7, insert the following code at the place indicated above:
If i = 7 Then
Beep
End If
Put a breakpoint at the "Beep" line and run.