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.
write to the file filename
{ item |
the class-name named item-name} |
every class-name [ filter ] |
the class hierarchy [of class-name] }
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:
write to the file "user/log/pump-1" pump-1
write to the file "user/log/pump-classes" every pump
** Gensym G2 Knowledge Base Inspection Output
** From KB: pump-text.kb
** File: /home/abc/pump-test.text
** Written at: 26 Jul 95 12:39:14 p.m.
** Command:
write to the file "/home/nrs/pump-test.text" every pump
** Results follow this line:
FUEL-PUMP-1, a fuel-pump
Notes OK
Item configuration none
Names FUEL-PUMP-1
Pressure 8
WATER-PUMP-1, a water-pump
Notes OK
Item configuration none
Names WATER-PUMP-1
Pressure 5
write to the file "/user/log/pump-status" every message
containing the word pump
For example, you could write a file that showed the class hierarchy of a particular class and all its instances:
write to the file "user/log/pump-classes" the class hierarchy of pump