Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top