next up previous

13.15.2.2 Printregion

The function printregion looks up a specified entry in a particular file which has been loaded previously into the lookup table and prints the contents of that entry to the specified output.

Syntax

(printregion <logical-name> <file-name> <topic-field>*)

where <logicalname> is a name previously attached to an output device. To send the output to stdout, specify t for the logical name. <filename> is the name of the previously loaded file in which the entry is to be found, and the optional arguments, <topicfield>*, is the full path of the topic entry to be found.

Each element or field in the path is delimited by white space, and the function is not case sensitive. In addition, the entire name of a field does not need to be specified. Only enough characters to distinguish the field from other choices at the same level of the tree are necessary. If there is a conflict, the function will pick the first one in the list. A few special fields can be specified.

^ Branch up one level.

? When specified at the end of a path, this forces a display of the current menu, even on branchups.

<nil> Giving no topic field will branch up one level.

The level of the tree for a file remains constant between calls to printregion. All levels count from menu only. Information levels do not count for branching up or down. To access an entry at the root level after branching down several levels in a previous call or series of calls, an equal number of branches up must be executed.

Examples

To display the entry for ROOT SUBTOPIC from the file foo.lis on the screen, type

(print-region t "foo.lis" ROOT SUBTOPIC)

or, using less characters,

(print-region t "foo.lis" roo sub)

Only one entry can be accessed per printregion call. The function returns the symbol TRUE if the printregion succeeded. If the entry was not found, it returns FALSE.

CLIPS> (fetch "foo.lis")
7
CLIPS> (print-region t "foo.lis" roo sub)
 --  Subtopic3 Text  --
TRUE
CLIPS> (print-region t "foo.lis" "?")
 --  Root3 Text  --
TRUE
CLIPS> (print-region t "foo.lis" ^ root1 sub)
 --  Subtopic1 Text  --
TRUE
CLIPS> (print-region t "foo.lis" sub)
 --  Subtopic4 Text  --
TRUE
CLIPS> (print-region t "foo.lis" ^ subtopic2)
 --  Subtopic2 Text  --
TRUE
CLIPS> (print-region t "foo.lis" ^ root2)
 --  Root2 Text  --
TRUE
CLIPS> (toss "foo.lis")
TRUE
CLIPS>


next up previous