| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (5 out of 12)

Writing Items to a File

You can use the Inspect facility to write a report to a file by using the write to file command. Write to the file allows you to inspect most of the same things that you can inspect with show on a workspace, except that G2 writes the results to a file instead of showing them on a temporary workspace.

The generated file contains a text heading indicating what knowledge base you inspected and the time when the report was generated. The contents of the file depend on what you are inspecting, as the following headings discuss.

The filename you specify can be a symbol if it just names a file. If it names a complete pathname, it must be a string. If you do not specify a file extension, G2 adds the suffix .qp. If you do not specify a directory, it writes to the current directory that is specified by the Load KB command.

Syntax

Writing Items

You can write the contents of any item, class of items, or item of a particular class with a particular name to a file. You can use any expression to identify the item or class.

The file contains the file header, the name of the item and its class, where relevant, the Name, Notes, and Item-configuration attributes for the item, and any user-defined attributes or specifications for the item.

For example, you might want to write a file of a particular item or a class of items:

The output file would be an ASCII text file that might look like this:

You might also issue the following command to write a file of all messages containing a certain word:

Writing a Class Hierarchy

You can write a class hierarchy to a file. The contents of the file includes the file header, a list of classes, appropriately indented to indicate the hierarchy, and the number of instances of each class.

For example, you could write a file that showed the class hierarchy of a particular class and all its instances:

| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (5 out of 12)

Copyright © 1997 Gensym Corporation, Inc.