Hello-

The code you've shown does everything but run the Rete engine, so no rules
are ever triggered.  While you can fetch the vector, it is still empty,
so calling elementAt on the vector throws the exception.  Insert the line:
        r.run();
before trying to process the results.

Also, you probably shouldn't be trying to reference a particular element
in a vector without trying to determine if the element exists, or else be
prepared to catch the index out of bounds exception.  Typically, one would
process a collection class object through an Enumeration or Iterator,
so that this is not a problem.

-Dave Barnett


On Fri, 14 Jul 2000, devdatt wrote:

> hai all
>    i am getting a problem in getting the Vector elements.
> 
> 
>   i have a clip file:
> 
>        (deftemplate ask (slot paper)(slot code))
>       (deffacts again (ask (paper one)(code code1))
>                               (ask (paper two)(code code2))
>                               (ask (paper one)(code code3))
>                          (ask (paper one)(code code3)))
> 
> 
>  in jess file ....
>  // when i tried to get the elements matched with paper one in rules RHS i
> am geting and ArrayIndexOutOfBounds Exception for the vector to where i want
> to store .
> 
>   // here is the code
>       Rete r= new Rete();
>       //functios
>       r.executeCommand("(defglobal ?*v* = (new Vector)) ");
>       r.executeCommand("(store RESULT ?*v* )");
>       r.executeCommand("(defrule urs (ask (paper one )(code ?z)) => (call
> ?*v* addElement ?z))
>       Vector sk=new Vector();
>        sk= (Vector)r.fetch("RESULT").externalAddressValue(null);
>       System.out.println("Element 1 " + sk.elementAt (0));
>     // here the elements are not being added and i am getting
> arrayindexoutof bounds exception
> //any one please help me......
> // lots of thanks in advance
> Dev.
> 
> 
> ---------------------------------------------------------------------
> 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]
> ---------------------------------------------------------------------
> 
> 

---------------------------------------------------------------------
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]
---------------------------------------------------------------------

Reply via email to