| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (18 out of 30)

make

Use the make action for three different purposes:

Making Transient Items Permanent

To enter the make permanent action:

This action makes a transient item, its attributes, its connections, and its subworkspace (and all their items, attributes and connections) permanent. Making a workspace permanent makes all items upon it permanent.

Once an item is permanent, G2 does not delete it when you reset your knowledge base. G2 retains the current state of the item including rotation, color, and location. G2 does not save the values of variables and parameters, or the elements of arrays and lists, unless their elements are permanent. For more information about permanent arrays and lists, see Chapter 16, Lists and Arrays.

There are two restrictions to making items exist permanently:

You can use the make permanent action on a permanent item to make a transient change permanent. For example, changing the array-length of a permanent array and subsequently using a make permanent action on that array retains the array length.

Here are examples of the make permanent action, one making a transient item permanent, and the other making transient changes to a permanent item permanent.


Making Permanent Items Transient

You can make a permanent item transient so that you can transfer it programmatically.


Tip: You do not have to make items transient to delete them. Permanent items can be deleted programmatically as described in Deleting Items Without First Making Them Transient.

To enter the make transient action:

This action makes a permanent item, its attributes, its connections, and its subworkspace (and all items, their attributes and connections on its subworkspace), or a workspace itself transient.

When you make an item transient, all of its connections become transient. When you make a workspace transient, all items upon it become transient.

The next example makes a parameter transient, creates a new workspace, and transfers the parameter to the new workspace.


Limitations to Transiency

An item cannot be made transient when any one of these conditions is true:

  1. The item is a class definition for an instantiated or subclassed class.

  2. The workspace hierarchy of the item contains a class definition for an instantiated or subclassed class. (When an item is made transient, all of the items within its workspace hierarchy are transient, too.)

  3. The item is an attribute value.

Making a Workspace the Subworkspace of an Item

To make a workspace the subworkspace of an item:

This action makes the specified kb-workspace a subworkspace of item. A workspace must be transient to become the subworkspace of an item. If the workspace is already an item's subworkspace, this action automatically changes its association with the original item and makes it the subworkspace of the target item.

If the target item already has a subworkspace, you must remove that subworkspace before executing this action by either transferring the subworkspace to another item, or deleting it.

The next example makes a subworkspace transient, makes it the subworkspace of an item, and makes it permanent.


Creating a Subworkspace Programmatically

Making a transient workspace the subworkspace of an item is part of creating a subworkspace programmatically. First, use the create action to create a workspace item, and then make it the subworkspace of the desired item.

Activation Status of Subworkspaces

You can enable or disable all workspaces and subworkspaces. Additionally, some subworkspaces are activatable, as described under activate. By default, workspaces and subworkspaces are enabled when G2 starts, while activatable subworkspaces are deactivated, and must be activated programmatically.

While the enabled and activated statuses of a subworkspace are separate properties, they can have similar results. For example, when G2 starts, it invokes every initially rule upon enabled workspaces and subworkspaces. Activating an activatable subworkspace at any time invokes any initially rules that reside upon it.

Making a workspace the subworkspace of another item usually has no effect on its enabled or activation status. An exception to this is making an activatable subworkspace, which is currently deactivated, the subworkspace of an item that is not configured to support activatable subworkspaces. Since the subworkspaces of items are enabled by default, executing such an action enables the previously deactivated subworkspace, which is akin to activating it.

| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (18 out of 30)

Copyright © 1997 Gensym Corporation, Inc.