import jess.*; public class ExMyUpcase implements Userfunction { // The name method returns the name by which the function will appear in Jess code. public String getName() { return "my-upcase"; } public Value call(ValueVector vv, Context context) throws JessException { return new Value(vv.get(1).stringValue(context).toUpperCase(), RU.STRING); } }
Every datum in Jess is represented by an object of jess.Value. The jess.Context represents an execution context for the evaluation of function calls and the resolution of variables. The jess.ValueVector class is Jess's internal representation of a list, and is used to represent multifields.
Jess> (load-function ExMyUpcase) Jess> (my-upcase foo)
import jess.*; public class ExPt { public static void main(String[] unused) throws JessException { Rete r = new Rete(); r.executeCommand("(batch jess/scriptlib.clp)"); r.executeCommand("(deftemplate point \"A 2D point\" (slot x) (slot y))"); r.executeCommand("(assert (point (x 37) (y 49)))"); r.executeCommand("(facts)"); } }
import jess.*; // ... // Create a Jess engine Rete rete = new Rete(); // Open the file test.clp FileReader fr = new FileReader("test.clp"); // Create a parser for the file, telling it where to take input // from and which engine to send the results to Jesp j = new Jesp(fr, rete); try { // parse and execute one construct, without printing a prompt j.parse(false); } catch (ReteException re) { // All Jess errors are reported as 'ReteException's. re.printStackTrace(rete.getErrStream()); }
(bind ?ht (new java.util.Hashtable)) (call ?ht put "key1" "element1") (call ?ht put "key2" "element2") (call ?ht get "key1")
java jess.Main
java jess.Console
Previous Message Handlers Up TOC Next Object Support