The Debugger button in the User Menu, which unlike most of the other commands in this menu is an internal command, brings up a panel which facilitates script development. The panel contains debugging options such as breakpoints, single-stepping, and text editing.
The text window displays the text of the currently loaded script. In editing mode, the verbatim text is shown. When not in editing mode, the text is shifted to the right by two columns, so that the first column can be used to indicate breakpoints and the current line.
The current mode (editing or executing) is switched by the button to the left of the title bar. The label of this button switches between ``Run'' and ``Edit'' to indicate the mode to switch to. In edit mode, the Execute menu is not available. In execute mode, the Edit menu is not available, and some functions in the File menu, such as New and Load, will switch back to edit mode.
While in editing mode, the text in the window can be edited, using the same keyboard commands as the text editor pop-up. The text is shown as it appears in the buffer, without the first two columns reserved for breakpoint indication as used outside of edit mode.
The following command buttons appear in the File menu.
The debugger text window serves as a drop receiver. Files can be loaded by dragging from the File Selection panel or another drag source, and dropping into the text window of the debugger, or the small ``load'' dialog window that receives the file name. The file name will be transferred to the load dialog, which will appear if not already present.
If, while in editing mode, the Ctrl key is held during the drop, the text will instead be inserted into the document at the insertion point.
The Edit menu contains commands specific to editing mode, and is disabled while in execute mode.
The remaining entries allow copying of selected text to and from other windows. These work with the clipboard provided by the operating system, which is a means of transferring a data item between windows on the desktop (see 3.13.3).
The Execute menu contains commands for executing the script in a controlled fashion. Displaying this menu switches to execute mode. The text is shifted to the right by two columns. The first column is used to indicate the next line to execute, and breakpoints.
The current line, which would be executed next, is shown with a colored `>' in the first column. Clicking on this line will cause the line to be executed, and the `>' will advance to the next executable line (the same as the Step menu item). Clicking on any other executable line of text in the text window will set a breakpoint, or clear the breakpoint if a breakpoint is already set on that line. A line containing a breakpoint is shown with a `B' in the first column. Execution, initiated with the Run button, will pause before the next line containing a breakpoint, after the current line.
In addition to the accelerators listed in the Execute menu, there are hard-coded accelerators for the menu functions.
|t, Space||single step|
A problem with the menu accelerators is that they require the Ctrl key to be pressed, which may fool scripts that are sensitive to the Ctrl key.
After the Monitor button is pressed, the user is prompted for the names of variables from the Xic prompt line. A list of variable names (space separated) is entered. A pop-up window will appear which lists these variables and their present values. If the variable is undefined or not in scope, the value will be ``???''. The values are updated after each line is executed. If, in response to the prompt for a list of variables, one enters ``all'' or ``*'' or ``.'', all of the variables currently in scope will be monitored.
Variables being displayed in the monitor window can be set to an arbitrary value by clicking on the variable name in the monitor window. The value will be prompted for on the Xic prompt line. Only variables that are in scope will accept a value. This feature can be used to alter program operation as the program is being run. Variables will continue to be monitored until the monitor window is dismissed.
The monitor window in the script debugger can handle multi-dimensional arrays. When specifying an array variable, the variable name can be followed by a range specification, enclosed in square brackets, as follows:
This is entirely optional, as are the individual entries. The three comma separated fields correspond to the three dimensions (maximum) of the array. The lowest dimension can be a range, where rmin and rmax set the range of indices to print or set. The remaining two fields are indices into the higher dimensions. These indices are taken as 0 if not given. One of the range values can be omitted, with the following interpretations:
|[rmin, ...||Use the single index rmin.|
|[rmin- , ...||Use the range rmin to the length of the lowest dimension.|
|[- rmax, ...||Use the range 0 - rmax.|
White space can appear, and the commas are optional, except in the second form above where a comma must follow the `-'.
If the rmax value is less than rmin, the printing order of the elements is reversed, as is the order of elements accepted when the variable is being set.
A similar range specification can be applied to string variables. In this case, only the first field is relevant, and the range applies to character positions.
The following commands are found in the Options menu of the editor. These commands are always available.
The search starts at the current text insertion point (the location of the I-beam cursor). This may not be visible in execute mode, but can be set by clicking with button 1 (which may set a breakpoint, so you will have to click again to remove it). The search does not wrap.