Hi,
You're confused about several points. ONe is that you're binding an
ordinary (not global) variable to a Vector, and then accessing it on
the RHS of your rules. Now, it turns out that this actually may work,
but it's actually undefined behaviour - it's not documented
anywhere. This menas that it might not always work, or it might not
work in the next Jess release. You could use a defglobal (which see,
in the manual) to hold your Vector.
Secondly, you're confusing the storage area used by fetch() and
store() with Jess variables. You can't get the value of a Jess
variable using fetch() - you can only get the values of things that
have been stored using store() (or (store) ). To get the value of a
global variable, you can use
Rete.getGlobalContext().getVariable(). Alternatively, you can use
fetch and store, but not use a defglobal at all.
I think s s wrote:
> hi
>
> I am trying to embed jess is java and having couple of issues.
> I have got a rules file called rules.clp. The outline
> of which is given below.
>
> (bind ?p (new java.util.Vector))
>
> (defrule Rule1
> LHS
> =>
> (call ?p addElement "value1")
>
> (defrule Rule2
> LHS
> =>
> (call ?p addElement "value2")
>
> I am using java to run this rule file. THe code I am using is given below.
>
> public class Test
> {
>
> public static void main(String [] argv) throws JessException
> {
> //Create Engine, load the rules to the jess engine
> Rete r = new Rete();
> FileReader rulesFile;
> Jesp jessParse;
> try {
> rulesFile = new FileReader("Rules.clp");
> }
> catch (FileNotFoundException fnfe) {
> rulesFile = null;
> System.out.println("Cannot open Rules.clp");
> }
>
> if (rulesFile != null) { //parse jess file
> jessParse = new Jesp(rulesFile, r);
> }
> r.executeCommand("(run)");
> Vector v = r.fetch("p");
> }
> }
>
> What I want to happen is get the Vector object that is declared in jess
> through java once the rules file is run.
> I tried to get the vector by using the fetch method. The program compiles
> alright. But I am getting an error while running the application. Would
> appreciate any help.
>
> Thanks
>
> Sobha
> ______________________________________________________
> Get Your Private, Free Email at http://www.hotmail.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]
> ---------------------------------------------------------------------
>
---------------------------------------------------------
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]
---------------------------------------------------------------------