Jess Fact Functions
List of functions for working with facts.
8.16. (assert <fact>+)
- Package:
-
Intrinsics
- Arguments:
-
One or more facts (not fact-IDs)
- Returns:
-
Fact-ID or FALSE
- Description:
-
Adds a fact to the fact list. Asserts all facts onto the fact list; returns
the fact-ID of last fact asserted or FALSE if no facts were successfully
asserted (for example, if all facts given are duplicates of existing facts.)
8.17. (assert-string <string-expression>)
- Package:
-
Intrinsics
- Arguments:
-
One string representing a fact
- Returns:
-
Fact-ID or FALSE
- Description:
-
Converts a string into a fact and asserts it. Attempts to parse string
as a fact, and if successful, returns the value returned by assert with
the same fact. Note that the string must contain the fact's enclosing parentheses.
8.52. (fact-id <integer>)
- Package:
-
Miscfunctions
- Arguments:
-
One number, a fact-id
- Returns:
-
The given number as an RU.FACT
- Description:
-
If the argument is the fact-id of an existing fact, returns the
number as a value of type RU.FACT; otherwise throws an exception.
8.53. (fact-slot-value <fact-id> <slot-name>)
- Package:
-
Scriptlib
- Arguments:
-
A fact-id and a slot name
- Returns:
-
(varies)
- Description:
-
Returns the value in the named slot of the fact with the given fact-id.
8.54. (facts)
- Package:
-
Scriptlib
- Arguments:
-
None
- Returns:
-
TRUE
- Description:
-
Prints a list of all facts on the fact list.
8.80. (load-facts <file-name>)
- Package:
-
Intrinsics
- Arguments:
-
A string or atom representing the name of a file of facts
- Returns:
-
Boolean
- Description:
-
Asserts facts loaded from a file. The argument should name a file containing
a list of facts (not deffacts constructs, and no other commands or constructs).
Jess will parse the file and assert each fact. The return value is the
return value of assert when asserting the last fact. In an applet, load-facts
will use getDocumentBase() to find the named file.
Note: See the batch command for a
discussion about specifying filenames in Jess.
8.93. (modify <fact-specified> <RHS-slot>*)
- Package:
-
Intrinsics
- Arguments:
-
A fact-ID and zero or more two-element lists
- Returns:
-
Fact-ID
- Description:
-
Modifies the deftemplate fact in the fact list. The fact-ID must belong
to an unordered fact. Each list is taken as the name of a slot in this
fact and a new value to assign to the slot. A new fact is asserted which
is similar to the given fact but which has the specified slots replaced
with new values. The original fact is retracted. The fact-ID of the new
fact is returned. Modifying a definstance fact will cause the
appropriate object properties to be set as well.
8.116. (retract <integer-expression>+)
- Package:
-
Intrinsics
- Arguments:
-
One or more fact-IDs (not integers)
- Returns:
-
TRUE
- Description:
-
Retracts the facts whose IDs are given. Retracting a definstance fact will
result in an implict call to undefinstance for the corresponding object
(the object will no longer be pattern-matched).
8.117. (retract-string <string>)
- Package:
-
Intrinsics
- Arguments:
-
A string, a representation of a Fact
- Returns:
-
TRUE
- Description:
-
Parses the string as a Fact; if such a fact exists on the knowledge
base, calls retract on it.
8.124. (save-facts <file-name> [<deftemplate-name>])
- Package:
-
Intrinsics
- Arguments:
-
A filename, and optionally an atom
- Returns:
-
Boolean
- Description:
-
Saves facts to a file. Attempts to open the named file for writing, and
then writes a list of all facts on the fact list to the file. This file
is suitable for reading with load-facts. If the optional second argument
is given, only facts whose head matches this atom will be saved. Does not
work in applets.
Note: See the batch command for a
discussion about specifying filenames in Jess.