The Expression (Expr) field is where you enter the data that you would like to evaluate. Once you've entered the data and pressed <Enter>, the result appears in the data display pane. This field provides automatic text completion.
Before doing this, you must compile your program using javac -g.
Use the left and right facing arrows that appear next to the Expr field to cycle through previous entries, or choose a symbol from the History menu on the menu bar.
You can choose display options from the choice menu that follows the left and right facing arrows.
The data you type in the Expr field can be of the following types:
Data Types | Example | Results |
symbol | x | Displays the value of the symbol. Display options depend on the symbol's data type. For example, an int can be displayed as Default, Decimal Octal, Hex, Type. |
object | this | Displays the contents of the object. Display options are Default, Type, Handle, Object-Text, Structure. |
array | arrayname | Displays the contents of the array. Options for display are Default, Type, Handle, Array-Text, Array-1D (for a one-dimensional array.) |
array[i] | arrayname[2] | Displays the contents of the specified array position. Display options depend on the symbol's data type. For example, an int can be Default, Decimal Octal, Hex, or Type. |
object.field | this.Color | Displays the contents of the specified field. Display options depend on the symbol's data type. For example, an int can be Default, Decimal Octal, Hex, or Type. |
Note: Evaluating the pseudo-variable "super" is not supported. You can work around this by displaying the derived class which shows the member fields inherited from its parents class.
When you enter an expression in the Expr field, or examine an expression in another card, the results of evaluating the expression are displayed on the left side of the Data card in a default format. The expression value is updated whenever a thread is suspended or a breakpoint is reached.
As your program runs, you can change a variable's value by double-clicking the current value and replacing it with the desired value. The variable must be of type boolean, int, short, byte, long, float, double, or char.
To view a value such as an object or an array in more detail, in the Source panel, double-click the value to display it in the data display panel. For example, if you are displaying an array of objects, double-click any one of the objects to display it in place of the entire array.
To control the way data is displayed, use the pop up menu above the display area. It provides display options appropriate for the type of data you are evaluating. You can modify values of type boolean, int, short, byte, long, float, double, or char by typing in a new value.
As an example, for object this (an instance of the Actor class in the Bounce demo applet), the following display options are available:
Default | Actor@b13ca0 |
Type | <object Actor> |
Handle | 0xb13ca0 |
Object-Text | 0xb08f48 Actor { String name = "Ball 2" Color color = java.awt.Color[r=255,g=0,b=0] Stage stage = Stage[0,0,300x218,layout=java.awt.FlowLayout] Thread runner = Thread[Ball 2,5,sun.applet.AppletViewer.main] double x0 = 290.1 double y0 = 27.6261 double v0x = -2 double v0y = 1.235 double ax = 0 double ay = 0.1 double x = 199.2 double y = 187.042 double t = 45.45 double dt = 0.05 int r = 10 } |
Structure | A table showing variable types, variables, and values. You can edit the values of the simple data types in the table. |
Need a suspended program to evaluate expressions | You are trying to evaluate a symbol while the program or thread is running. Suspend the thread before evaluating the symbol. |
no such symbol | The symbol you have entered does not exist in the current thread or the current stack frame. |
not in scope | The data you are trying to evaluate is not within the scope of the program (not known to the program) at this point in execution. |
no such field | The field you are trying to evaluate does not exist in this object. |
The right side of the display area provides a table that allows you to select expressions and view or update expression values as your program runs. Use the pop up menu above the view area to select either the "Custom" or "Locals" view. The default view is "Custom."
Both views display a two-column table. The left column contains variables or expressions and the right column contains values. You can change the format of values using the right-mouse-button menu, or you can modify values of type boolean, int, short, byte, long, float, double, or char by typing in a new value.
The Add button allows you to move an item from the Expr field to the Expression/Value table where values are updated during the running of the program.
Menu Item | Description |
Clear | Removes an expression from the table. |
Insert | Inserts a new row in the table above the current row. |
Delete | Deletes the current row. |
Guide to the Cosmo Code Development Environment
12-96*219