Hi,
I am having difficulty passing values from Java to
Jess and then back to Java. I have the following
code. Could someone tell me what I'm doing wrong??
===================================================
testJess.java
===================================================
import java.io.*;
import java.awt.*;
import jess.*;
import java.util.*;
public class testJess
{
public static void main(String[] argv)
{
try
{
Rete rete = new Rete();
Context c = rete.getGlobalContext();
rete.executeCommand("(reset)");
rete.addUserpackage(new PredFunctions());
rete.addUserpackage(new MiscFunctions());
rete.reset();
// Read in the rules
rete.executeCommand("(batch test.clp)");
System.out.println("Initial state = " +
rete.fetch("currentState"));
//rete.store("currentState", new Value(2,
RU.INTEGER));
rete.executeCommand("(assert
(run-until-halt))");
rete.executeCommand("(assert (handle-up))");
System.out.println("Listing facts...");
for (Enumeration e = rete.listFacts();
e.hasMoreElements();) {
Object t = e.nextElement();
System.out.println(t.toString());
}
System.out.println("Current State after assert
on handle-up = " + rete.fetch("RESULT"));
rete.executeCommand("(assert (stop-exec))");
}
catch (JessException re)
{
re.printStackTrace();
}
}
}
===================================================
test.clp
===================================================
(set-reset-globals nil)
(store currentState "idle")
(defrule handle-up-rule
(handle-up)
=>
(store RESULT "handle-up")
)
(defrule end-exec
(stop-exec)
=>
(halt)
)
===================================================
output
===================================================
Initial state = "idle"
Listing facts...
(initial-fact)
(run-until-halt)
(handle-up)
Current State after assert on handle-up = null
===================================================
My question is: why doesn't the 'Current State after
assert on handle-up' say 'handle-up'?
Thanks in advance.
__________________________________________________
Do You Yahoo!?
Send instant messages with Yahoo! Messenger.
http://im.yahoo.com/
---------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the
list (use your own address!) List problems? Notify [EMAIL PROTECTED]
---------------------------------------------------------------------