Hi ,
I am calling user defined function in the rule (in the body of the rule).
This function is called using the �test CE�.
My query is how to explicitly pass the Context object to this user function call in the defrule?.I tried looking the manual and API but was not able to get the syntax.
My requirement is that called user function does some modifications to the Context object passed to it.
Here is an example
This is the class for defining the user function:
package edu.umbc.cs.D2J;
import jess.*;
public class POC implements Userfunction{
public String getName() { return "try"; }
public Value call(ValueVector vv, Context context) throws JessException
{
System.out.println("I am being called");
/****** passed context changed *****/
context.setVariable("third", new Value("check" ,RU.STRING));
System.out.println("context aft= " + context);
return new Value( new Boolean(true));
}
}
This is the class which calls the function:
package edu.umbc.cs.D2J;
import jess.*;
public class ExAddUF
{
public static void main(String[] argv) throws JessException
{
Rete r = new Rete();
r.addUserfunction(new POC());
r.executeCommand("(reset)");
r.executeCommand("(bind ?x 123)");
Context myContext = null;
System.out.println(r.getGlobalContext());
/****** here the unser function is called ****/
r.executeCommand("(defrule abc (test(try 123)) => (assert (check 345)))");
r.executeCommand("(run)");
r.executeCommand("(facts)");
}
}
in the defrule when I am calling try method I want to pass the myContext object as an parameter.
What is the syntax for it?
Thank you.
Regards,
Mahesh G.
Do You Yahoo!?
Yahoo! Greetings - send greetings for Easter, Passover
