One of the most valuable things a programmer can learn about a failed program is what happens to the variables at different points in the program. By examining variable values, the programmer can determine which variables are being assigned incorrectly, and thus find out which statements are not being executed properly.
The /* command displays all variables in the symbol table. All variables are reported, including file variables, select-list variables and dimensioned array variables. For example:
*/* FILEVAR PROGRAM=TESTIT FILE.ARRAY(1,1)=JOEY FILE.ARRAY(1,2)=FRED FLINTS . . . |
By using the /* command, the user can scan the values for all variables at once. However, the /* command will not give the user the opportunity to change any values, and if there are many variables or some extremely long string variables, the values may scroll past the screen too quickly.
The values of simple variables can be printed and (optionally) reassigned with the / command.
Format
/var |
Parameter(s)
var |
Variable name. |
Description
A single variable can be displayed with the / command and the variable name. The user will be shown the current value, and be prompted with an equals sign to change the value at will. Whatever the user types before pressing ENTER becomes the new value for the variable.
For example, to display the current value of the variable STRING, the user might type:
*/STRING |
The Debugger will respond with the current value of STRING and an equals (=) sign. If STRING contains the word HELLO, the user sees the following with the underscore representing the user’s cursor position:
*/STRING<ENTER> HELLO=_ |
The user can then enter a value for STRING and press ENTER. To leave the value unchanged, the user should press ENTER without reassigning the variable.
The values of a single element or of all elements of a dimensioned array can also be printed and (optionally) reassigned with the / command.
Format
/array [(n [,m])] |
Parameter(s)
array |
Name of the dimensioned array. |
n |
Row number of the array element. If omitted, all elements of the array will be printed. |
m |
Column number of the array element. If array is two-dimensional, m must be supplied if n is supplied. |
Description
The individual elements of a dimensioned array can be treated like simple variables by referencing them with parentheses.
Example
To display the current value of element 2,3 of array NAME.ARRAY, the user might enter:
*/NAME.ARRAY(2,3) |
The Debugger will respond with the current value of NAME.ARRAY(2,3) and an equals sign. If element 2,3 contains HERB, the user would see:
*/NAME.ARRAY(2,3)<ENTER> HERB=_ |
(with the underscore representing the user’s cursor position).
The user then has the option to fill in a value for NAME.ARRAY(2,3), or to leave it unchanged by pressing ENTER.
Alternatively, all elements of a dimensioned array can be displayed and changed by omitting the element reference. For example, to display the current values of all elements of array NAME.ARRAY, the user can type:
*/NAME.ARRAY |
and will be prompted with the value of each element of the array as if each were specified individually. For example:
*/NAME.ARRAY<ENTER> NAME.ARRAY(1,1)="JOEY"= NAME.ARRAY(1,2)="FRED FLINTS"=_ . . . |
The value of some string variables might be too long to be printed on a single screen. For these strings, the [ command should be used to specify a subset of each string to be printed.
Format
[n,m] |
Parameter(s)
n |
Starting column of the substring. |
m |
Length of the substring. If 0, turn off string windowing. |
Description
If n and m are omitted, string windowing is turned off.
Example
Suppose the string RECORD contains over a hundred addresses separated by attribute marks, totaling over 2000 characters. When the user tries to print the output of RECORD in the Debugger, the entire screen is filled and the beginning of the string is scrolled off the screen. The programmer is only interested in characters towards the middle of the string; therefore, the number of characters printed out should be limited with:
*[800,400] */RECORD |
By limiting the output to 400 characters, the relevant portion of RECORD can be made accessible to the programmer.
See Also