| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (4 out of 9)

Creating, Populating, and Saving a Module

The basic tasks for working with modules are:

For information about creating and saving a hierarchy of modules, see Creating a Module Hierarchy.

Naming the Top-Level Module

The first step in creating a module is to name the top-level module. This is true whether you are creating modules in an empty KB, or in a KB that already contains items.

Naming the top-level module creates a module of that name in the current KB. If you want the current KB to have a single module only, all you have to do to create the module is to name it.

You can name the top-level module interactively or programmatically.

To name the top-level module interactively:

  1. Open the Module Information system table by selecting:

    Main Menu > System Tables > Module Information 
  2. Enter the name of the top-level module in the Top-level-module attribute:


    You can enter any unreserved symbol as the name of the top-level module.

To name the top-level module programmatically:

where module-name is the symbolic name of the module.

If you have named a top-level module in the current KB, each time you create a new top-level workspace, G2 automatically assigns the workspace to the top-level module.


Note: If you delete the top-level module from the current KB before saving, G2 deletes any new top-level workspaces that you have created during your G2 session. For more information, see Deleting a Module.

Naming Conventions for Modules

When naming the top level or other modules, we recommend following the standard naming conventions described in Syntax for KB Filenames.

Associating Items With a Module

After creating a module, you typically associate the module with a set of items in the current KB. You do this by associating the module with a top-level KB workspace. G2 associates the module with this workspace and with all items below the workspace in the workspace hierarchy.

To associate a module with a top-level workspace interactively:

  1. Open the table for a top-level workspace.

  2. Enter the name of a module in the Module-assignment attribute.

    You can enter only one module name in this attribute.

To associate a module with a top-level workspace programmatically:

where module-name is the name of the module to which you wish to assign kb-workspace.


Tip: You can assign more than one top-level KB workspace to the same module. However, we recommend that you assign only one top-level workspace to a module. By observing this convention, your modularized KBs have a predictable structure, and are more convenient to work with.

If the current KB has a top-level module, and you add a new top-level workspace to the current KB, G2 automatically sets its Module-assignment attribute to the name of the top-level module.

Saving a Module in a Separate KB File

When your KB contains a single top-level module, you can save the module in its own KB file. For information about saving a modularized KB, see Saving the Module Hierarchy.

You can save modules interactively or programmatically.

To save a module in a file interactively:

  1. Select Main Menu > Save KB.

    G2 displays a special workspace for saving KBs, which shows:

    The following figure shows the save KB workspace that G2 displays when saving the test-module module:


  2. At this point you can:

    1. Enter a new default directory path and filename of the KB file into which you want to save the module

    2. Enter just a new filename

    3. Accept the default filename


Tip: We recommend that you name the KB file using the same name as the module it contains. This is especially critical when saving modularized KB, as explained in
Specifying the Filename of a Saved Module.

To save a module programmatically:

You can programmatically save a module, even while the current KB is running.

| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (4 out of 9)

Copyright © 1997 Gensym Corporation, Inc.