| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (3 out of 6)

Attribute Descriptions

The ability to access system-defined attributes directly makes it possible to change their values. To do so, however, requires knowledge of the structure of each class attribute, called its attribute description.

Attribute descriptions present the internal data structure and type of each accessible attribute in a system-defined class. You need to know this information before accessing and manipulating system-defined attributes.

Obtaining Class Descriptions

The G2 Class Reference Manual presents an alphabetical listing of:

The information is generated automatically from the internal structures of G2 to ensure its accuracy and validity. Refer to the G2 Class Reference Manual to determine the accessibility of any system-defined attribute.

In the class dictionary, all attribute names and their subattributes appear in bold type. Each attribute description includes this information:

This information... Describes...
attribute-name
A symbol of the attribute name.
text-readable
Truth-value indicating whether it is possible to use the expression:
text-writable
Truth-value indicating whether it is possible to set the attribute value using the action:
value-readable
Truth-value indicating whether it is possible to use the expression:
value-writable
Truth-value indicating whether it is possible to set the value of the attribute using the action:
is-system-defined
Truth-value indicating whether an attribute is system- or user-defined. This attribute is true for all system-defined classes.
defining-class
A symbol value indicating the class in which the attribute is defined, which could be the current class or a superior class.

You can also obtain the descriptions programmatically from G2, using the system procedure g2-get-attribute-descriptions-of-class.

Differences Between the Value and Text of an Attribute

The G2 Class Reference Manual describes whether an item attribute is:

The readability and writability of an item determines the way in which you can access a system-defined attribute. For example, if an attribute is defined as only text-readable, you can refer to that attribute using the text of expressions, but you cannot change the attribute, either through a change the text of statement or a conclude that the x of y expression.

This is the way you can refer to or change system-defined attributes:

If an attribute is: You can:
text-readable
Refer to it as:
value-readable
Refer to it as:
text-writable
Change its value using:
value-writable
Change its value using:

Viewing an Attribute Value or Text

When attributes are both text- and value-readable, you can view them both as a text and as a value.

Consider the Class-specific-attributes attribute of a class definition, which is text- and value-readable and text- and value-writable. If you create a class definition called test-class, which defines two class-specific attributes as follows:

then returning the value of this attribute, using the expression:

would consist of this sequence of structures:

Returning the text of this attribute, using the expression:

would consist of this text:

Referencing Limited-Access Attributes

Some system-defined attributes have a limited access to their textual representation and values. Such attributes are those that either have:

All system-defined attributes are minimally readable, and may also be writable. Some attributes are text- or value-readable, or both. A complete list of system-defined attributes with limited access is not given here, because it may change. However, the next table presents some examples of attributes that have various combinations or text- and value-accessibility:

Attribute Text-readable Value-readable Text-writable Value-writable
Format-of-image




Item-status




Notes




Authors




Change-log




KB developers can determine the status of each attribute's text-readable, text-writable, value-readable, and value-writable access by referring to the G2 Class Reference Manual, or by testing for these attributes programmatically as described next.

Example of Obtaining an Attribute Description

You can use the g2-get-attribute-descriptions-of-class system procedure to return the attribute description of one or more attributes programmatically. You can then test any aspect of the attribute to determine its functionality.

As an example, the next procedure accepts any class and a sequence of attribute names as its arguments, and then tests to see if each attribute is value-writable, indicating that you can conclude a value into it:


When called with the arguments to get information about two attributes of a G2-WINDOW object:

to test whether you can conclude a value into the Item-configuration and G2-user-mode attributes of a window object, the procedure determines that the first attribute is value-writable, but that the second attribute is not.

The next figure shows these results:


Thus, you must use change the text of statements to change the G2-user-mode attribute of the current window programmatically.

Hidden Attributes

Some system-defined attributes are not visible in an item's attribute table, but are accessible programmatically, such as:

These attributes are referred to as hidden attributes. Hidden attributes of items appear in the G2 Class Reference Manual and in their attribute descriptions, and are programmatically accessible, but they do not appear in the item attribute table. These are some frequently encountered hidden attributes of items:

Hidden attribute Description
evaluation-attributes
Two attributes referring to the computational aspects of G2 items. See Evaluation Attributes.
history
A structure for providing history values and their collection times.
history-using-unix-time
The POSIX-compliant timestamp indicating when each history value is saved.
user-restrictions
A superseded hidden attribute; replaced with Item-configuration.
name-box
The structure of an item's name box when it is visible, including its position as an offset to the item.
attribute-displays
The structure for the attribute displays of each item attribute.
icon-variables
A structure of the variables you can define within an icon. Every iconic system- and user-defined class has at least two icon variables: width and height. User-defined classes can include other icon variables. For more information about icon-variables, see Chapter 37, The Icon Editor and Icon Management.
relationships
The relations in which an item participates. This attribute returns a sequence of structures, as described in Referring to The Relationships of an Item.

Evaluation Attributes

The evaluation-attributes hidden attribute contains two characteristics of G2 items and how they participate in KB processing. Only one evaluation attribute is actively used.

The evaluation attributes are:

Evaluation attribute Description
may-refer-to-inactive-items
A truth-value indicating whether the item can reference items that are disabled or deactivated. This subattribute must be set to true for G2 to be able to invoke the event detection rule: For more information about this rule, see Whenever Rules.
may-run-while-inactive
An unsupported truth-value subattribute, for future use.

Composite Attributes

Some attributes are composed of more than one subattribute, which you can refer to individually. The Notes attribute is an example of a composite attribute. These are the subattributes of Notes:

Attribute Description
item-status
A symbol used to indicate item status. The value can be OK, INCOMPLETE, or BAD. You can refer to the value of this attribute, but not its text. You cannot change the text or the value of item-status.
item-notes
The additional part of the item Notes attribute, specified as a sequence of text strings, describing notes about an item.

To reference both of its subattribute values requires two expressions:

where the item-status returns the standard OK, INCOMPLETE, or BAD status, and item-notes returns a sequence of text values with actual notes.

| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (3 out of 6)

Copyright © 1997 Gensym Corporation, Inc.