SendCommand() is a function that has been provided to closely emulate a CLIPS shell environment. In fact, CLIPS does not provide this when used as a library, it has been coded implementing the same operations that are performed in the CLIPS command loop, except for the input part of course. This allows also to issue some commands that fail when called using the Eval() function. For an example, consider the following session:
>>> t = clips.BuildTemplate("car", "(slot make)(slot model)") >>> f0 = t.BuildFact() >>> f0.Slots['make'] = clips.Symbol('Chevy') >>> f0.Slots['model'] = clips.Symbol('Prizm') >>> f0.Assert() >>> clips.PrintFacts() f-0 (car (make Chevy) (model Prizm)) For a total of 1 fact. >>> clips.Eval("(modify 0 (make Geo))") Traceback (most recent call last): File "<pyshell#20>", line 1, in -toplevel- clips.Eval("(modify 0 (make Geo))") File ".../_clips_wrap.py", line 3227, in Eval ClipsError: C10: unable to evaluate expression >>> print clips.ErrorStream.Read().strip() [TMPLTFUN1] Fact-indexes can only be used by modify as a top level command. >>>
Whereas, if you use SendCommand(), the same expression actually becomes a top level command, and it is executed in the expected way:
>>> clips.SendCommand("(modify 0 (make Geo))") >>> clips.PrintFacts() f-1 (car (make Geo) (model Prizm)) For a total of 1 fact. >>>
There are other actions that behave differently when "evaluated" compared to when executed at the CLIPS shell prompt or within a Load() call: the SendCommand() function can also be used as a shortcut in these cases.