Using Attribute Tables
You can view and edit item attributes interactively by displaying an attribute table or by interacting with attribute displays.
To display an item's attribute table:
- Click any item to display its menu.
- Choose table. Here is the attribute table of an action button:
Note: The ability to display an attribute table assumes that the item has not been configured to behave otherwise. Configurations are described in Chapter 7, Configurations.
Programmatically, you can change attribute values and show and hide attribute displays. The next figure shows an action button that has two attribute displays, and shows an attribute table for the button.
An attribute table displays the item's class, user-specified name, the names of the item's attributes, and the current value of each attribute. If the item has a text attribute, for example, the text attribute of a rule, the attribute table displays that value in its own row.
This figure shows the organization of an attribute table:

|
Updating Attribute Tables Automatically
G2 continuously updates each attribute table's display when the values of the displayed attributes change. For this reason, displaying an attribute table is a convenient way to monitor an item's attributes as you develop your KB.
You can open more than one attribute table for the same item. When you edit an attribute interactively, or when your KB programmatically changes an attribute value, that change is reflected almost immediately in all attribute tables that are open for that item.
In an attribute table, G2 indicates that a value has expired by displaying the characters ***. Since only the value of a variable can expire, an expired value can occur in:
Attribute Table Display Precision
In an attribute table, G2 displays each float value with no more than three digits of precision to the right of the decimal point. Thus, G2 displays the float value 0.333456 as 0.333. If you reenter a value with only three digits of precision, other significant digits of the original number are lost.
To display the float value of an attribute with greater precision, use a readout table whose Expression-to-display attribute specifies a formatting expression, such as dd.ddddd.
Positioning an Attribute Table
By default, an attribute table does not reside upon any workspace. However, you can use the mouse to drag an attribute table anywhere within the G2 window. Attribute tables also respond to G2's system-defined keystroke commands for moving workspaces, such as Control + u and Control + d, to move it up and down, respectively. You can also transfer an attribute table to a KB workspace, as described in the next section.
Attribute tables persist after you reset or restart the current KB. An attribute table is not an item, so G2 does not save it when you save the current KB into a KB file.
Using Attribute Table Menus
Using the menu for an attribute table, you can edit the values of editable attributes, create attribute displays, and create and display subtables of attributes that contain objects.
To display a table menu:
The choices shown on a table menu depend upon whether you clicked in a row that displays an editable attribute or a noneditable attribute.
To edit an attribute value:
This opens the Text Editor. You use the Text Editor to change the value of any editable attribute. For information on interacting with the Text Editor, see Chapter 36, The Text Editor.
Note: In some cases, clicking on the value of an attribute in a table immediately opens the Text Editor. This behavior depends on the class-specific attribute.
Transferring an Attribute Table
To transfer an attribute table means to place it upon a KB workspace.
A transferred attribute table has a special status within your KB:
To transfer an entire attribute table to a workspace:
- Click in one of the cells of the attribute table to display the table menu:
- Choose
transfer. G2 attaches an outline of the table to the mouse pointer.
- Drag the attribute table to any displayed workspace, including the workspace on which you are currently displaying the table.
- Click the mouse to place the table on the workspace. The workspace borders move outward as necessary to include the table. The double outer border of a transferred attribute table changes to a single border.
- After transferring an attribute table to a workspace, subsequently clicking on its title bar displays a two choice menu, rather than automatically hiding the table:
Note: You cannot programmatically transfer a table, and you cannot programmatically move a table that is on a workspace.
Displaying the Subtable for an Attribute that Contains an Object
A user-defined attribute of a user-defined object class can contain as its value:
The object contained in the attribute of an item is called a subobject. A subobject has its own table associated with it, called a subtable. The table menus and menu choices that appear in a subtable are no different from those for attribute tables. The only difference is that they pertain to the attributes of the object contained in the attribute.
Tip: Defining an Attribute as an Object Instance describes how to define class-specific attributes whose values are object instances, including variables, and parameters.
To display the subtable for an attribute that contains an object:
The fact that this table contains the subtable menu choice by default indicates that the value of this attribute is an object.
Note: You cannot delete the subtable for a class-specific attribute that is declared to be an instance of some object class, or given by a variable or parameter.
The next figure shows the icons for an object class definition and an instance of that class:
The CUSTOM-LOGICAL-VARIABLE definition defines a subclass of the system-defined LOGICAL-VARIABLE class, and custom-variable-1 is the instance. The figure also shows the table menu that appears when you click on the attribute table row for the user-defined attribute named Custom-object, which is defined to contain an item-array.
Selecting the subtable menu choice displays the subtable for an item-array, as shown in the next figure:

|
Creating a Subtable for an Attribute
You can interactively create a subtable for an attribute so that it contains an object. The result is similar to defining a class-specific attribute in the definition of a class to be an instance of some object class or given by a variable or parameter.
You can interactively add a subtable to any untyped attribute, or any attribute that has a default value; you cannot interactively add a subtable to a typed attribute. For information on defining class-specific, typed and untyped attributes in a class definition, see Defining and Initializing Class-Specific Attributes.
To add a subtable to an attribute interactively:
- Click on an untyped attribute in an attribute table to display the table menu.
- Select the
add optional subtable menu option.
G2 displays a menu of all system-defined and user-defined object classes:
- Choose a class.
G2 adds a subobject of the specified class to the attribute and an associated subtable. The table menu for the attribute now displays the subtable menu choice for displaying the interactively created subtable.
To delete an interactively created subtable for an attribute:
Copyright © 1997 Gensym Corporation, Inc.