Jess Rules Engine Commands

List of engine commands that can be executed by Jess.


8.13. (agenda)

Package:
MiscFunctions
Arguments:
None
Returns:
NIL
Description:
Displays a list of rule activations to the WSTDOUT router.

8.19. (batch <filename>)

Package:
Miscfunctions
Arguments:
One string or atom representing the name of a file
Returns:
(Varies)
Description:
Attempts to parse and evaluate the given file as Jess code. If successful, returns the return value of the last expression in the file.

Note: the argument must follow Jess' rules for valid atoms or strings. On UNIX systems, this presents no particular problems, but Win32 filenames may need special treatment. In particular: pathnames should use either '\\' (double backslash) or '/' (forward slash) instead of '\' (single backslash) as directory separators; and pathnames which include a colon (':') or a space character (' ') must be enclosed in double quotes.

In an applet, batch will try to find the file relative to the applet's document base. In any program, if the file is not found, the name is then passed to ClassLoader.getSystemResourceAsStream(). This allows files along the class path, including files in JARs, to be batched.

8.24. (bload <filename>)

Package:
DumpFunctions
Arguments:
One string or atom representing the name of a file
Returns:
TRUE
Description:
The argument is the name of a file previously produced by the bsave command. The file is decompressed and deserialized to restore the state of the current Rete object. I/O routers are not restored from the file; they retain their previous state. Furthermore, JessListeners are not restored from the file; again, they are retained from their state prior to the bload.

8.25. (bsave <filename>)

Package:
DumpFunctions
Arguments:
One string or atom representing the name of a file
Returns:
TRUE
Description:
Dumps the engine in which it is called to the given filename argument in a format that can be read using bload. Any input/output streams and event listeners are not saved during the serialization process.

8.26. (build <string-expression>)

Package:
Miscfunctions
Arguments:
One string representing some Jess code
Returns:
(Varies)
Description:
Evaluates a string as though it were entered at the command prompt. Only allows constructs to be evaluated. Attempts to parse and evaluate the given string as Jess code. If successful, returns the return value of the last expression in the string. This is typically used to define rules from Jess code. For instance:

(build "(defrule foo (foo) => (bar))")

Note: The string must consist of one single construct; multiple constructs can be built using multiple calls to build.

8.29. (clear)

Package:
Intrinsics
Arguments:
None
Returns:
TRUE
Description:
Clears Jess. Deletes all rules, deffacts, defglobals, deftemplates, facts, activations, and so forth. Java Userfunctions are not deleted.

8.36. (defadvice (before | after) (<function-name> | <multifield> ) <function-call>+)

Package:
Intrinsics
Arguments:
The atom before or the atom after, followed by either one function name or a multifield of function names or the atom ALL, followed by one or more function calls.
Returns:
(varies)
Description:
Lets you supply extra code to run before or after the named function(s) or all functions. If before is specified, the code will execute before the named function(s); the variable $?argv will hold the arguments to the function on entry to and exit from the code block. If after is specified, the function will be called before the code block is entered. When the block is entered, the variable ?retval will refer to the original function's return value.

Whether before or after is specified, if the code block explicitly calls return with a value, the returned value will appear to the caller to be the return value of the original function. For before advice, this means the original function will not be called in this case.

8.41. (do-backward-chaining <deftemplate-tag>)

Package:
Intrinsics
Arguments:
Name of a deftemplate (ordered or unordered)
Returns:
TRUE
Description:
Marks a deftemplate as being eligible for backwards chaining, as described in the text.

8.43. (engine)

Package:
MiscFunctions
Arguments:
None
Returns:
External address
Description:
Returns an external-address object containing the Rete engine in which the function in called.

8.46. (eval <lexeme-expression>)

Package:
Intrinsics
Arguments:
One string containing a valid Jess expression
Returns:
(Varies)
Description:
Evaluates a string as though it were entered at a command prompt. Only allows functions to be evaluated. Evaluates the string as if entered at the command line and returns the result.

Note: The string must consist of one single function call; multiple calls can be evaluated using multiple calls to eval.

8.48. (exit)

Package:
Intrinsics
Arguments:
None
Returns:
Nothing
Description:
Exits Jess and halts Java.

8.65. (get-reset-globals)

Package:
MiscFunctions
Arguments:
None
Returns:
Boolean
Description:
Indicates the current setting of global variable reset behavior. See set-reset-globals for an explanation of this property.

8.66. get-salience-evaluation

Package:
MiscFunctions
Arguments:
None
Returns:
Atom
Description:
Indicates the current setting of salience evaluation behavior. See set-salience-evaluation for an explanation of this property.

8.67. (halt)

Package:
Intrinsics
Arguments:
None
Returns:
TRUE
Description:
Halts rule execution. No effect unless called from the RHS of a rule.

8.114. (reset)

Package:
Intrinsics
Arguments:
None
Returns:
TRUE
Description:
Removes all facts from the fact list, removes all activations, then asserts the fact (initial-fact), then asserts all facts found in deffacts, asserts a fact representing each registered definstance, and (if the set-reset-globals property is TRUE) initializes all defglobals.

8.121. (run [<integer>])

Package:
Intrinsics
Arguments:
Optionally, a single integer
Returns:
TRUE
Description:
Starts the inference engine. If no argument is supplied, Jess will keep running until no more activations remain or halt is called. If an argument is supplied, it gives the maximum number of rules to fire before stopping.

8.123. (run-until-halt)

Package:
Scriptlib
Arguments:
None.
Returns:
int
Description:
Runs the engine until halt is called. Returns the number of rules fired. When there are no active rules, the calling thread will be blocked waiting on the activation semaphore.

8.129. (set-node-index-hash <integer>)

Package:
MiscFunctions
Arguments:
One integral value
Returns:
TRUE
Description:
Sets the default hashing key used in all Rete network join node memories defined after the function is called; this function will not affect parts of the network already in existence at the time of the call. A small value will give rise to memory-efficient nodes; a larger value will use more memory. If the created nodes will generally have to remember many partial matches, large numbers will lead to faster performance; the opposite may be true for nodes which will rarely hold more than one or two partial matches. This function sets the default; explicit declare statements can override this for specific rules.

8.130. (set-reset-globals (TRUE | FALSE | nil))

Package:
MiscFunctions
Arguments:
One boolean value (TRUE or FALSE or nil)
Returns:
Boolean
Description:
Changes the current setting of the global variable reset behavior. If this property is set to TRUE (the default), then the (reset) command reinitializes the values of global variables to their initial values (if the initial value was a function call, the function call is reexecuted.) If the property is set to FALSE or nil, then (reset) will not affect global variables. Note that in previous versions of Jess, defglobals were always reset; but if the initial value was set with a function call, the function was not reevaluated. Now it is.

8.131. (set-salience-evaluation (when-defined | when-activated | every-cycle))

Package:
MiscFunctions
Arguments:
One of the atoms when-defined, when-activated, or every-cycle
Returns:
One of the potential arguments (the previous value of this property)
Description:
Changes the current setting of the salience evaluation behavior. By default, a rule's salience will be determined once, when the rule is defined (when-defined.) If this property is set to when-activated, then the salience of each rule will be redetermined immediately before each time it is placed on the agenda. If the property is set to every-cycle, then the salience of every rule is redetermined immediately after each time any rule fires.

8.132. (set-strategy (depth | breadth))

Package:
MiscFunctions
Arguments:
An atom or string representing the name of a strategy (can be a fully-qualifed Java class name). You can use depth and breadth to represent the two built-in strategies.
Returns:
The previous strategy as an atom.
Description:
Lets you specify the conflict resolution strategy Jess uses to order the firing of rules of equal salience. Currently, there are two strategies available: depth (LIFO) and breadth (FIFO). When the depth strategy is in effect (the default), more recently activated rules are fired before less recently activated rules of the same salience. When the breadth strategy is active, rules of the same salience fire in the order in which they are activated. Note that in either case, if several rules are activated simultaneously (i.e., by the same fact-assertion event) the order in which these several rules fire is unspecified, implementation-dependent and subject to change. More built-in strategies may be added in the future. You can (perhaps) implement your own strategies in Java by creating a class that implements the jess.Strategy interface and then specifying its fully-qualified classname as the argument to set-strategy. Details can be gleaned from the source. At this time, though, I think some of the methods you'd need to call are package-protected.

8.154. (undefadvice (<function-name> | ALL | <multifield>))

Package:
Intrinsics
Arguments:
A function name, or ALL, or a multifield of function names
Returns:
TRUE
Description:
Removes all advice from the named function(s).

8.156. (undefrule <rule-name>)

Package:
Intrinsics
Arguments:
An atom representing the name of a rule
Returns:
Boolean
Description:
Deletes a defrule. Removes the named rule from the Rete network and returns TRUE if the rule existed. This rule will never fire again.