1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702
|
% $Id: contents.tex 334 2008-01-12 04:10:30Z Franz $
\chapter{Module Contents\label{pyclips-modulecontents}}
This chapter gives a detailed description of top-level functions and
constants in the \pyclips{} module. It's not intended to be a CLIPS
reference: the official CLIPS Reference Guide still remains the main
source of documentation for this. This Guide will often be referred to
for information about the engine itself, and the user is expected to
know the CLIPS language and structure sufficiently with respect to his
goals.
Although the \pyclips{} user is not supposed to know CLIPS API, it is
advisable to have its reference at least at hand to sometimes understand
\emph{how} \pyclips{} interacts with CLIPS itself. Besides the programmatic
approach offered by \pyclips{} is vastly different to the C API -- with
the occasional exception of the intrinsic logic.
We will first describe the top level functions.
\section{Top Level Functions and Constants\label{pyclips-toplevel}}
\subsection{Constants\label{pyclips-tl-constants}}
Several constants are provided in order to configure CLIPS environment
or to instruct some functions to behave in particular ways.
\subsubsection{Scope Save Constants}
Constants to decide what to save in CLIPS dump files (see the
\function{SaveInstances()}, \function{BSaveInstances()} and
\function{SaveFacts()} functions).
\begin{tableii}{l|l}{constant}{Constant}{Description}
\lineii{LOCAL_SAVE}{save objects having templates defined
in current \class{Module}}
\lineii{VISIBLE_SAVE}{save all objects visible to current
\class{Module}}
\end{tableii}
\subsubsection{Salience Evaluation Constants}
Constants to tell the underlying engine when salience has to be
evaluated (see the \var{EngineConfig.SalienceEvaluation} property).
\begin{tableii}{l|l}{constant}{Constant}{Description}
\lineii{WHEN_DEFINED}{evaluate salience on rule definition
(the default)}
\lineii{WHEN_ACTIVATED}{evaluate salience on rule activation
(\emph{dynamic salience})}
\lineii{EVERY_CYCLE}{evaluate salience on every execution
cycle (\emph{dynamic salience})}
\end{tableii}
\subsubsection{Conflict Resolution Strategy Constants}
Constants to specify the way the underlying engine should resolve
conflicts among rules having the same salience (see the
\var{EngineConfig.Strategy} property).
\begin{tableii}{l|l}{constant}{Constant}{Description}
\lineii{DEPTH_STRATEGY}{newly activated rule comes first}
\lineii{BREADTH_STRATEGY}{newly activated rule comes last}
\lineii{LEX_STRATEGY}{strategy based on \emph{time tags}
applied to facts}
\lineii{MEA_STRATEGY}{strategy based on \emph{time tags}
applied to facts}
\lineii{COMPLEXITY_STRATEGY}{newly activated rule comes before
rules of lower \emph{specificity}}
\lineii{SIMPLICITY_STRATEGY}{newly activated rule comes before
rules of higher \emph{specificity}}
\lineii{RANDOM_STRATEGY}{assign place in agenda randomly}
\end{tableii}
In the table above, the term \emph{specificity} refers to the number
of comparisons in the LHS of a rule.
\subsubsection{Class Definition Default Mode Constants}
Constants to specify default mode used for classes definition. Please
refer to \clipsbpg{} for details about the usage of the two modes, as
the meaning is quite complex and outside the scope of this manual
(see the \var{EngineConfig.ClassDefaultsMode} property).
\begin{tableii}{l|l}{constant}{Constant}{Description}
\lineii{CONVENIENCE_MODE}{set the default class mode to
\keyword{convenience}}
\lineii{CONSERVATION_MODE}{set the default class mode to
\keyword{conservation}}
\end{tableii}
\subsubsection{Message Handler Type Constants}
Constants to define the execution time, the purpose and the behaviour of
\emph{message handlers}: see function \function{BuildMessageHandler()}
and the following members of the \class{Class} class:
\function{AddMessageHandler()} and \function{FindMessageHandler()}.
The following table summarizes the analogous one found in \clipsbpg{}.
\begin{tableii}{l|l}{constant}{Constant}{Description}
\lineii{AROUND}{only to set up an environment for the message}
\lineii{AFTER}{to perform auxiliary work after the primary message}
\lineii{BEFORE}{to perform auxiliary work before the primary message}
\lineii{PRIMARY}{to perform most of the work for the message}
\end{tableii}
\subsubsection{Template Slot Default Type Constants}
It's possible to inspect whether or not a \class{Template} slot has been
defined to have a default value, and in case it is, if its default value
is \emph{static} (that is, constant) or \emph{dynamically generated} (for
instance, using a function like \code{gensym}). See the documentation of
\class{Template} for more details.
\begin{tableii}{l|l}{constant}{Constant}{Description}
\lineii{NO_DEFAULT}{the slot has no default value}
\lineii{STATIC_DEFAULT}{the default value is a constant}
\lineii{DYNAMIC_DEFAULT}{the default value is dynamically generated}
\end{tableii}
Notice that \constant{NO_DEFAULT} evaluates to \constant{False}, so it's
legal to use the \function{Template.Slot.HasDefault()} function just to
test the presence of a default value. Please also note that
\constant{NO_DEFAULT} is only returned when the default value for a slot
is set to \code{?NONE} as stated in the \clipsapg{}.
\subsection{Functions\label{pyclips-tl-functions}}
\begin{funcdesc}{AgendaChanged}{}
test whether or not \code{Agenda} has changed since last call.
\end{funcdesc}
\begin{funcdesc}{Assert}{o}
Assert a \class{Fact} (already created or from a string). This perhaps
needs some explanation: CLIPS allows the creation of \code{fact}s based
on \class{Template}s, and in \pyclips{} this is done by instancing a
\code{Fact} with a \class{Template} argument. The resulting \class{Fact}
slots can then be modified and the object can be used to make an
assertion, either by using the \class{Fact} \function{Assert()}
function or this version od \function{Assert()}.
\end{funcdesc}
\begin{funcdesc}{BLoad}{filename}
Load the constructs from a binary file named \var{filename}. Binary
files are not human-readable and contain all the construct information.
\end{funcdesc}
\begin{funcdesc}{BLoadInstances}{filename}
Load \class{Instance}s from binary file named \var{filename}. Binary
files are not human-readable and contain all the construct information.
\end{funcdesc}
\begin{funcdesc}{BSave}{filename}
Save constructs to a binary file named \var{filename}.
\end{funcdesc}
\begin{funcdesc}{BSaveInstances}{filename \optional{, mode=\constant{LOCAL_SAVE}}}
Save \class{Instance}s to binary file named \var{filename}. The
\var{mode} parameter can be one of \constant{LOCAL_SAVE} (for all
\class{Instance}s whose \class{Definstance}s are defined in current
\class{Module}) or \constant{VISIBLE_SAVE} (for all \class{Instance}s
visible to current \class{Module}).
\end{funcdesc}
\begin{funcdesc}{BatchStar}{filename}
Execute commands stored in text file named as specified in \var{filename}.
\end{funcdesc}
\begin{funcdesc}{BrowseClasses}{name}
Print the list of \class{Class}es that inherit from specified one.
\end{funcdesc}
\begin{funcdesc}{Build}{construct}
Build construct given in argument as a string. The string must enclose
a full construct in the CLIPS language.
\end{funcdesc}
\begin{funcdesc}{BuildClass}{name, text \optional{, comment}}
Build a \class{Class} with specified name and body. \var{comment} is
the optional comment to give to the object. This function is the only
one that can be used to create \class{Class}es with multiple
inheritance.
\end{funcdesc}
\begin{funcdesc}{BuildDeffacts}{name, text \optional{, comment}}
Build a \class{Deffacts} object with specified name and body.
\var{comment} is the optional comment to give to the object.
\end{funcdesc}
\begin{funcdesc}{BuildDefinstances}{name, text \optional{, comment}}
Build a \class{Definstances} having specified name and body.
\var{comment} is the optional comment to give to the object.
\end{funcdesc}
\begin{funcdesc}{BuildFunction}{name, args, text \optional{, comment}}
Build a \class{Function} with specified name, arguments and body.
\var{comment} is the optional comment to give to the object. \var{args}
can be either a blank-separated string containing argument names, or
a sequence of strings corresponding to argument names. Such argument
names should be coherent to the ones used in the function body (that is,
\var{text}). The argument list, if expressed as a string, should
\emph{not} be surrounded by brackets. \var{None} can also be used as
the argument list if the function has no arguments.
\end{funcdesc}
\begin{funcdesc}{BuildGeneric}{name, text \optional{, comment}}
Build a \class{Generic} with specified name and body. \var{comment} is
the optional comment to give to the object.
\end{funcdesc}
\begin{funcdesc}{BuildGlobal}{name, \optional{, value}}
Build a \class{Global} variable with specified \var{name} and \var{value}.
The \var{value} parameter can be of any of the types supported by CLIPS:
it can be expressed as a Python value (with type defined in Python: the
module will try to pass to CLIPS a value of an according type), but for
types that normally do not exist in Python (such as \class{Symbol}s) an
explicit conversion is necessary. If the \var{value} is omitted, then
the module assigns \var{Nil} to the variable.
\end{funcdesc}
\begin{funcdesc}{BuildInstance}{name, defclass \optional{, overrides}}
Build an \class{Instance} of given \class{Class} overriding specified
\code{slots}. If no \code{slot} is specified to be overridden, then the
\class{Instance} will assume default values.
\end{funcdesc}
\begin{methoddesc}{BuildMessageHandler}{name, class, args, text \optional{, type, comment}}
Add a new \emph{message handler} to the supplied class, with specified
name, body (the \var{text} argument) and argument list: this can be
specified either as a sequence of variable names or as a single string
of whitespace separated variable names. Variable names (expressed as
strings) can also be \emph{wildcard parameters}, as specified in the
\clipsbpg{}. The \var{type} parameter should be one of \var{AROUND},
\var{AFTER}, \var{BEFORE}, \var{PRIMARY} defined at the module level:
if omitted it will be considered as \var{PRIMARY}. The body must be
enclosed in brackets, as it is in CLIPS syntax. The function returns
the \emph{index} of the \emph{message handler} within the specified
\class{Class}.
\end{methoddesc}
\begin{funcdesc}{BuildModule}{name \optional{, text, comment}}
Build a \class{Module} with specified name and body. \var{comment} is
the optional comment to give to the object. The current \class{Module}
is set to the new one.
\end{funcdesc}
\begin{funcdesc}{BuildRule}{name, lhs, rhs \optional{, comment}}
Build a \class{Rule} object with specified name and body. \var{comment}
is the optional comment to give to the object. The \var{lhs} and
\var{rhs} parameters correspond to the \emph{left-hand side} and
\emph{right-hand side} of a \class{Rule}.
\end{funcdesc}
\begin{funcdesc}{BuildTemplate}{name, text \optional{, comment}}
Build a \class{Template} object with specified name and body.
\var{comment} is the optional comment to give to the object.
\end{funcdesc}
\begin{funcdesc}{Call}{func, args}
Call a CLIPS internal \class{Function} with the given argument string.
The \var{args} parameter, in its easiest form, can be a list of arguments
separated by blank characters using CLIPS syntax. There are other forms
that can be used, depending on how many arguments the called function
requires: if it accepts a single argument, the caller can just specify
the argument\footnote{It must be of a type compatible with CLIPS. If a
string is supplied, however, it will be considered as a list of arguments
separated by whitespace: in order to explicitly pass a string it has
either to be converted or to be specified surrounded by double quotes.}
possibly cast using one of the \emph{wrapper classes} described below. When
the function accepts multiple arguments it is possible to specify them
as a sequence of values (either a list or a tuple) of basic\footnote{Complex
values, as \emph{multifield}, are not supported: CLIPS does not allow
external calls with non-constant arguments and there is no possibility
to build a \emph{multifield} in place without an explicit function call.}
values. It is always preferable to convert these values using the
\emph{wrapper classes} in order to avoid ambiguity, especially in case of
string arguments.
\end{funcdesc}
\begin{funcdesc}{ClassList}{}
Return the list of \class{Class} names.
\end{funcdesc}
\begin{funcdesc}{Clear}{}
Clear current \class{Environment}.
\end{funcdesc}
\begin{funcdesc}{ClearPythonFunctions}{}
Unregister all user defined Python functions from \pyclips{}.
\end{funcdesc}
\begin{funcdesc}{ClearFocusStack}{}
Clear focus stack.
\end{funcdesc}
\begin{funcdesc}{CurrentEnvironment}{}
Return an \class{Environment} object representing current CLIPS
\emph{environment}. This is useful for switching between \emph{environment}s
in a \pyclips{} session. Please note that almost all \emph{environment}
operations are disallowed on the returned object until another
\class{Environment} is selected as current: all operations on current
\class{Environment} should be performed using the \emph{top level}
module functions.
\end{funcdesc}
\begin{funcdesc}{CurrentModule}{}
Return current module as a \class{Module} object.
\end{funcdesc}
\begin{funcdesc}{DeffactsList}{}
Return a list of \class{Deffacts} names in current \class{Module}.
\end{funcdesc}
\begin{funcdesc}{DefinstancesList}{}
Retrieve list of all \class{Definstances} names.
\end{funcdesc}
\begin{funcdesc}{Eval}{expr}
Evaluate expression passed as argument. Expressions that only have
\emph{side effects} (e.g. \code{printout} expressions) return
\constant{None}.
\end{funcdesc}
\begin{funcdesc}{ExternalTracebackEnabled}{}
Return \constant{True} if functions called from within CLIPS using the
engine function \code{python-call} will print a standard traceback to
\var{sys.stderr} on exceptions, \constant{False} otherwise. This function
is retained for backwards compatibility only: please use the
\var{ExternalTraceback} flag of the \var{DebugConfig} object to enable or
disable this feature instead.
\end{funcdesc}
\begin{funcdesc}{FactList}{}
Return list of \class{Fact}s in current \class{Module}.
\end{funcdesc}
\begin{funcdesc}{FactListChanged}{}
Test whether \class{Fact} list is changed since last call.
\end{funcdesc}
\begin{funcdesc}{FindClass}{name}
Find a \class{Class} by name.
\end{funcdesc}
\begin{funcdesc}{FindDeffacts}{name}
Find a \class{Deffacts} by name.
\end{funcdesc}
\begin{funcdesc}{FindDefinstances}{name}
Find a \class{Definstances} by name.
\end{funcdesc}
\begin{funcdesc}{FindFunction}{name}
Find a \class{Function} by name.
\end{funcdesc}
\begin{funcdesc}{FindGeneric}{name}
Find a \class{Generic} function by name.
\end{funcdesc}
\begin{funcdesc}{FindGlobal}{name}
Find a \class{Global} variable by name.
\end{funcdesc}
\begin{funcdesc}{FindInstance}{name}
Find an \class{Instance} in all \class{Module}s (including imported).
\end{funcdesc}
\begin{funcdesc}{FindInstanceLocal}{name}
Find an \class{Instance} in non imported \class{Module}s.
\end{funcdesc}
\begin{funcdesc}{FindModule}{name}
Find a \class{Module} in list by name.
\end{funcdesc}
\begin{funcdesc}{FindRule}{name}
Find a \class{Rule} by name.
\end{funcdesc}
\begin{funcdesc}{FindTemplate}{name}
Find a \class{Template} by name.
\end{funcdesc}
\begin{funcdesc}{FocusStack}{}
Get list of \class{Module} names in focus stack.
\end{funcdesc}
\begin{funcdesc}{FunctionList}{}
Return the list of \class{Function} names.
\end{funcdesc}
\begin{funcdesc}{GenericList}{}
Return the list of \class{Generic} names.
\end{funcdesc}
\begin{funcdesc}{GlobalList}{}
Return the list of \class{Global} variable names.
\end{funcdesc}
\begin{funcdesc}{GlobalsChanged}{}
Test whether or not \class{Global} variables have changed since last
call.
\end{funcdesc}
\begin{funcdesc}{InitialActivation}{}
Return first \class{\class{Activation}} object in current CLIPS
\class{Environment}.
\end{funcdesc}
\begin{funcdesc}{InitialClass}{}
Return first \class{Class} in current CLIPS \class{Environment}.
\end{funcdesc}
\begin{funcdesc}{InitialDeffacts}{}
Return first \class{Deffacts} in current CLIPS \class{Environment}.
\end{funcdesc}
\begin{funcdesc}{InitialDefinstances}{}
Return first \class{Definstances} in current CLIPS \class{Environment}.
\end{funcdesc}
\begin{funcdesc}{InitialFact}{}
Return first \class{Fact} in current CLIPS \class{Environment}.
\end{funcdesc}
\begin{funcdesc}{InitialFunction}{}
Return first \class{Function} in current CLIPS \class{Environment}.
\end{funcdesc}
\begin{funcdesc}{InitialGeneric}{}
Return first \class{Generic} in current CLIPS \class{Environment}.
\end{funcdesc}
\begin{funcdesc}{InitialGlobal}{}
Return first \class{Global} variable in current CLIPS
\class{Environment}.
\end{funcdesc}
\begin{funcdesc}{InitialInstance}{}
Return first \class{Instance} in current CLIPS \class{Environment}.
\end{funcdesc}
\begin{funcdesc}{InitialModule}{}
Return first \class{Module} in current CLIPS \class{Environment}.
\end{funcdesc}
\begin{funcdesc}{InitialRule}{}
Return first \class{Rule} in current CLIPS \class{Environment}.
\end{funcdesc}
\begin{funcdesc}{InitialTemplate}{}
Return first \class{Template} in current CLIPS \class{Environment}.
\end{funcdesc}
\begin{funcdesc}{InstancesChanged}{}
Test if \class{Instance}s have changed since last call.
\end{funcdesc}
\begin{funcdesc}{Load}{filename}
Load constructs from the specified file named \var{filename}.
\end{funcdesc}
\begin{funcdesc}{LoadFacts}{filename}
Load \class{Fact}s from the specified file named \var{filename}.
\end{funcdesc}
\begin{funcdesc}{LoadFactsFromString}{s}
Load \class{Fact}s from the specified string.
\end{funcdesc}
\begin{funcdesc}{LoadInstances}{filename}
Load \class{Instance}s from file named \var{filename}.
\end{funcdesc}
\begin{funcdesc}{LoadInstancesFromString}{s}
Load \class{Instance}s from the specified string.
\end{funcdesc}
\begin{funcdesc}{MessageHandlerList}{}
Return list of \class{MessageHandler} constructs.
\end{funcdesc}
\begin{funcdesc}{MethodList}{}
Return the list of all methods.
\end{funcdesc}
\begin{funcdesc}{ModuleList}{}
Return the list of \class{Module} names.
\end{funcdesc}
\begin{funcdesc}{PopFocus}{}
Pop focus.
\end{funcdesc}
\begin{funcdesc}{PrintAgenda}{}
Print \class{Rule}s in \code{Agenda} to standard output.
\end{funcdesc}
\begin{funcdesc}{PrintBreakpoints}{}
Print a list of all breakpoints to standard output.
\end{funcdesc}
\begin{funcdesc}{PrintClasses}{}
Print a list of all \class{Class}es to standard output.
\end{funcdesc}
\begin{funcdesc}{PrintDeffacts}{}
Print a list of all \class{Deffacts} to standard output.
\end{funcdesc}
\begin{funcdesc}{PrintDefinstances}{}
Print a list of all \class{Definstances} to standard output.
\end{funcdesc}
\begin{funcdesc}{PrintFacts}{}
Print \class{Fact}s to standard output.
\end{funcdesc}
\begin{funcdesc}{PrintFocusStack}{}
Print focus stack to standard output.
\end{funcdesc}
\begin{funcdesc}{PrintFunctions}{}
Print a list of all \class{Function}s to standard output.
\end{funcdesc}
\begin{funcdesc}{PrintGenerics}{}
Print list of \class{Generic} functions to standard output.
\end{funcdesc}
\begin{funcdesc}{PrintGlobals}{}
print a list of \class{Global} variables to standard output
\end{funcdesc}
\begin{funcdesc}{PrintInstances}{\optional{class}}
Print a list of \class{Instance}s to standard output. If the \var{class}
argument is omitted, all \class{Instance}s in the subsystem will be
shown. The \var{class} parameter can be a \class{Class} object or a
string containing a \class{Class} name.
\end{funcdesc}
\begin{funcdesc}{PrintMessageHandlers}{}
Print a list of all \class{MessageHandler}s.
\end{funcdesc}
\begin{funcdesc}{PrintModules}{}
Print a list of \class{Module}s to standard output.
\end{funcdesc}
\begin{funcdesc}{PrintRules}{}
Print a list of \class{Rule}s to standard output.
\end{funcdesc}
\begin{funcdesc}{PrintSubclassInstances}{\optional{class}}
Print subclass \class{Instance}s to standard output for the
\class{Class} specified. If the \var{class} argument is omitted, all
instances in the subsystem will be shown. The \var{class} parameter can
be a string containing a \class{Class} name or a \class{Class} object.
\end{funcdesc}
\begin{funcdesc}{PrintTemplates}{}
Print \class{Template} names to standard output.
\end{funcdesc}
\begin{funcdesc}{RefreshAgenda}{}
Refresh \code{Agenda} \class{Rule}s for current \class{Module}.
\end{funcdesc}
\begin{funcdesc}{RegisterPythonFunction}{callable \optional{, name}}
Register the function \function{callable} for use within CLIPS via the
engine function \code{python-call}. If the parameter \var{name} of type
\class{str} is not given, then the \var{__name__} attribute of the
first argument will be used. \var{name} is the name that will be used
in CLIPS to refer to the function. See appendix for a more detailed
explanation.
\end{funcdesc}
\begin{funcdesc}{ReorderAgenda}{}
Reorder \code{Agenda} \class{Rule}s for current \class{Module}.
\end{funcdesc}
\begin{funcdesc}{Reset}{}
Reset current \class{Environment}.
\end{funcdesc}
\begin{funcdesc}{RestoreInstancesFromString}{s}
Restore \class{Instance}s from the specified string.
\end{funcdesc}
\begin{funcdesc}{RuleList}{}
Return a list of \class{Rule} names in current \class{Module}.
\end{funcdesc}
\begin{funcdesc}{Run}{\optional{limit}}
Execute \class{Rule}s up to \var{limit} (which is an \class{int} if
given). If \var{limit} is omitted, then no limitation is assumed and the
program runs countinuously until all rules are executed. The function
returns the number of rules that have been fired\footnote{This means,
for instance, that continuously using this function and checking whether
or not the result is less than the specified limit can give more control
over the running CLIPS subprogram, eventually giving the ability to
actively check for the end of the program.}.
\end{funcdesc}
\begin{funcdesc}{Save}{filename}
Save constructs to the file specified by \var{filename}. The constructs are
saved in text (human readable) form.
\end{funcdesc}
\begin{funcdesc}{SaveFacts}{filename \optional{, mode=\constant{LOCAL_SAVE}}}
Save current \class{Fact}s to file specified by \var{filename}. The
\var{mode} parameter can be one of \constant{LOCAL_SAVE} (for all
\class{Fact}s whose \class{Template}s are defined in current
\class{Module}) or \constant{VISIBLE_SAVE} (for all \class{Fact}s
visible to current \class{Module}).
\end{funcdesc}
\begin{funcdesc}{SaveInstances}{filename \optional{, mode=\constant{LOCAL_SAVE}}}
Save \class{Instance}s to file specified by \var{filename}. The
\var{mode} parameter can be one of \constant{LOCAL_SAVE} (for all
\class{Instance}s whose \class{Definstance}s are defined in current
\class{Module}) or \constant{VISIBLE_SAVE} (for all \class{Instance}s
visible to current \class{Module}).
\end{funcdesc}
\begin{funcdesc}{SendCommand}{cmd \optional{, verbose=\constant{False}}}
Send a command to the underlying CLIPS engine, as if it was typed at the
console in an interactive CLIPS session. This command could actually be
useful when embedding a CLIPS shell in a Python program. Please note that
other input than commands, in such a case, should be entered using the
\var{StdinStream} input stream. If \var{verbose} is set to \constant{True}
the possible\footnote{Except for the CLIPS printing functions, as for
instance \code{printout}, that issue an output even when the flag is not
set.} command output is sent to the appropriate output stream.
\end{funcdesc}
\begin{funcdesc}{SetExternalTraceback}{\optional{enabled=\constant{True}}}
Allow or disallow functions called from within the CLIPS engine using
\code{python-call} to print a standard traceback to \var{sys.stderr} in
case an exception occurs. Please note that this does not mean that a
real exception arises, as there is no possibility to catch Python
exceptions in CLIPS code. In such case all failing Python functions will
return the symbol \code{FALSE} to CLIPS\footnote{This is not always an
error condition because a function can intentionally return boolean
values to CLIPS. However the CLIPS engine will report an error message
which can be read from the error stream.}. This behaviour is initially
set to \constant{False}, as it is useful only for debugging purposes.
This function is retained for backwards compatibility only: please use the
\var{ExternalTraceback} flag of the \var{DebugConfig} object to enable or
disable this feature instead.
\end{funcdesc}
\begin{funcdesc}{ShowGlobals}{}
Print list of \class{Global} variables and their values to standard
output (the \function{PrintGlobals()} functions only prints out
\class{Global} variable names).
\end{funcdesc}
\begin{funcdesc}{TemplateList}{}
Return a list of \class{Template} names.
\end{funcdesc}
\begin{funcdesc}{UnregisterPythonFunction}{name}
Remove the function referred as \var{name} within the CLIPS engine from
the set of functions that can be called via \code{python-call} calls.
\end{funcdesc}
Among other exception types, arising in cases that can also occur in
Python, the \pyclips{} module can raise exceptions specific to CLIPS
identified by the following:
\begin{excdesc}{ClipsError}
Exception raised when an operation fails in the CLIPS subsystem: normally
it occurs when CLIPS finds an error, when an iteration is over or when an
invalid value is passed to CLIPS. This exception is accompanied by
explanatory text preceded by an alphanumeric code that can be used
to programmatically identify the error.
\end{excdesc}
\begin{excdesc}{ClipsMemoryError}
Severe memory error raised when the CLIPS subsystem is unable to allocate
the needed memory. In normal circumstances, when an error of this type
occurs, the CLIPS system has become inconsistent and the only way to
recover is exiting. This exception is raised only in order to allow a
developer to notify the user of the impossibility to continue.
\end{excdesc}
\begin{seealso}
\sclipsapg{}
\sclipsbpg{}
\end{seealso}
|