next up previous contents index
Next: The Rehash Button: Rebuild Up: The User Menu: User Previous: Encrypted Scripts   Contents   Index

The Debug Button: Enter Script Debugger

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 determined by which of the File or Execute drop-down menus was last visited. Opening the File menu switches to editing mode. Execution mode is set when the Execute menu is opened.

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 New button in the File menu will clear the previous contents of the text window, allowing a new script to be keyed in. If the previous script is modified and not saved, a message will inform the user, and the text will not be cleared. Pressing the New button a second time will clear the text, and the previous changes will be lost.

The Save button in the File menu allows the contents of the text window to be saved in a file. The user is prompted for the name of the file, the default being the original file name, if any. A pre-existing file of the same name will be retained with a ``.bak'' extension.

The Open button in the File menu will prompt for the name of a script file, which will be loaded into the debugger. A full path must be given to the file, if the file is not in the script search path. If, while the open pop-up is active, a script is selected in the User Menu, that script name will be loaded into the open dialog text area. Files can also 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.

The Print button in the File menu brings up a control panel for sending the contents of the text window to a printer, or to a file.

The Quit button in the File menu will retire the debug panel, which is the same effect as pressing the Debugger button in the User Menu a second time. If there is unsaved text, a message will alert the user, and the panel will not be withdrawn. Pressing the Quit button a second time will retire the panel without saving changes. The debugger can also be dismissed with the window manager ``delete window'' function, which has the same effect as the Quit button.

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.

The Run command in the Execute menu will cause lines of the script to be executed until a line containing a breakpoint or the end of the script is reached. Pressing Ctrl-C will cause the script to pause at the next line.

The Step command in the Execute menu causes the current line to be executed, and the current line pointer will be advanced to the next line.

The Reset button in the Execute menu will reset the current line to the start of the script.

Under Unix/Linux, in addition to the accelerators listed in the Execute menu, there are hard-coded accelerators for the menu functions.

t, Space single step
r run
e, Backspace reset

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.

The Monitor button in the Execute menu allows variables to be monitored and set. 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:

[rmin-rmax,dim2,dim3]

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.


next up previous contents index
Next: The Rehash Button: Rebuild Up: The User Menu: User Previous: Encrypted Scripts   Contents   Index
Stephen R. Whiteley 2006-10-23