3

I want to send a "fact" to a JESS file within java and get the results back. I basicly batch the JESS file and then send my data (structure in here) into the engine by .add(). I tried to get the JESS results, which should be a string, into a "Value".

Rete engine = new Rete();
engine.batch("file.clp");
Value = AAAnull;
try{
   engine.add(structure)
   AAA = engine.eval("(run)");
   } catch ...

System.out.println(AAA);

The result is always a number, although the result should be a string. I have worked it out in a simple java project and the AAA is returning the string, but here it is not working.

POD
  • 509
  • 8
  • 20

1 Answers1

2

The (run) function returns the number of rules fired; that's the number you're seeing here.

The real results of running your program are the side effects it causes; getting the result in Java depends on what side effects you're expecting. That may mean anything from collecting output printed to the screen, finding newly created facts in working memory, or having your Jess program call Java methods that effect the outside world. Without seeing the contents of file.clp I can't say what you're expecting, but all of these things listed are covered in the Jess manual; the phrases above are links to the appropriate sections. I'm happy to answer any followup questions you might have.

Ernest Friedman-Hill
  • 80,601
  • 10
  • 150
  • 186
  • thanks, I will go through the manual first and see what I can find out – POD Apr 20 '13 at 03:35
  • I came to another problem. When I am trying to run the Rete engine in a actionlistnere, the engine is not running and I do not get any feedback from it. Is it because the engine is used inside a actionlistener? – POD Apr 20 '13 at 06:16
  • No, that shouldn't be a problem. You can use the `(watch all)` command to see more of what Jess is doing and that might help. – Ernest Friedman-Hill Apr 20 '13 at 12:00