| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (11 out of 14)

Accessing Lists or Arrays that are Object Attributes

User-defined objects can have attributes that are instances of lists and arrays. In a class definition, you specify such an attribute with a statement such as:

where attribute-name is the name of the attribute you are specifying, and g2-list or g2-array is any applicable G2-LIST or G2-ARRAY class or subclass. To distinguish lists and arrays that are object attributes, this section refers to them as attribute lists and arrays.

When objects with such attributes are instantiated, the lists or arrays exist as separate items within the KB. You can access a list or array that is an attribute by naming it. You can name attribute lists and arrays interactively by accessing the subtable from the object's attribute table, or programmatically with statements such as:

You can also use attribute access to reference and change most attribute values, as described in Chapter 12, Attribute Access Facility.

Changing Attribute List and Array Elements

To provide new element values to attribute list and arrays without names, use the change action with the following syntax:

where attribute is the attribute name, object is the object, followed by the element index, and item-or-value is the new value to assign to that array or list element.

The conclude actions uses two similar syntactical forms to produce different results.

Concluding an Unnamed Object Attribute that is a List or an Array

To provide a new element value to an unnamed attribute list or array, use this syntax:

Concluding a List or Array Element that is an Object

To change the attribute value of an object that is a list or array element, use this syntax:

| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (11 out of 14)

Copyright © 1997 Gensym Corporation, Inc.