> You can, of course, pass a Context as a regular argument to a
> function, which perhaps makes more sense here, anyway;
can you tell me syntax for this ie passing Context as an argument.
here method "Call" is not called explicitly .
its invoked in defrule in the body of the rule in the test clause. so how to pass context during this
invocation.
Regards,
Mahesh G.
[EMAIL PROTECTED] wrote:
The Context object is analagous to the call stack in languages like C
and Java. Just as there's no language-level mechanism in those
languages to call a function with a user-specified stack, there's no
such mechanism in Jess, either.
You can, of course, pass a Context as a regular argument to a
function, which perhaps makes more sense here, anyway; or the function
might get the context using (fetch), or a defglobal, or some Java
global or static function -- or member function in the POC
class... there are many possibilities.
I think Mahesh Gandhe wrote:
>
> 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[] arg! v) 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
---------------------------------------------------------
Ernest Friedman-Hill
Distributed Systems Research Phone: (925) 294-2154
Sandia National Labs FAX: (925) 294-2234
Org. 8920, MS 9012 [EMAIL PROTECTED]
PO Box 969 http://herzberg.ca.sandia.gov
Livermore, CA 94550
--------------------------------------------------------------------
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]
--------------------------------------------------------------------
Do You Yahoo!?
Yahoo! Greetings - send greetings for Easter, Passover
