Hi,

Not a stupid question at all. store() and fetch() are not magic at
all; they're just trivial functions and Userfunctions wrapping a
java.util.Hashtable. When you call store() you put something into the
Hashtable, and when you call fetch, you get it out. You could write
your own version which just appended everything to a single Vector,
then use it instead of what you've got below; i.e., something like

public class StoreVector implements Userfunction {
        private static Vector m_vector = new Vector();
        public static Vector getVector() { return m_vector; }
        public static void clear() { m_vector.setLength(0); }
        public String name() { return "store-vec"; }
        public Value call(ValueVector vv, Context c)
                throws JessException {
                m_vector.addElement(vv.get(1).resolveValue(c));
                return Funcall.TRUE;
        }
}

Then in your Jess code you'd call (store-vec ?v1) to add a result, and
in Java you'd do something like

        StoreVector.clear();
        engine.run();
        Vector results = StoreVector.getVector();

If you wanted the entries keyed by some rule identifier, then
you could write a version which took two arguments, and pass in the
rule name from Jess when you call store-vec.

I think Manish Sannat wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> I am loading Rules and Facts dynamically and I want to get result(Action) of fired 
>rules in the form
> of Vector of result strings.
> I know that you can store the result string as
> (defrule rule1
>  (head1 ?var1) 
> (head2 ?var2)
>  => 
> (assert (head3 ?v1 ?v2))
>  (store v1 ?var1)
> (store v2 ?var2) )
> ....................
> and get it in java as 
> after loading rules and facts and  rete.run();
>               Value v1Value = new Value(String s1, RU.STRING);
>               v1Value = rete.fetch("v1");
>               ValueVector vv = new ValueVector(); 
>               vv.add(v1Value); 
> 
> Is there in other way or design pattern through which result of fired rules can be 
>sored in the form 
> of Vector(or ValueVector) without knowing the stored Value variable (in the RHS of 
>rules ;in the example above "v1").
> I may sound fool but I mean after (run) ;it should store all the fired rules RHS to 
>a list(or Vector).
> Like : public ValueVector run()  throws JessException;
> where ValueVector has structure of Elements ((ruleNo. or any other identifier for 
>key), String[]).
> Sorry, if I have asked stupid Que.
> Manish
> 
> 
> 
> 
> 
> MASTEK
> Investing in relationships
> In the US, we're called MAJESCO
> 
> 
>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Opinions expressed in this e-mail are those of the individual and not that of Mastek 
>Limited, unless specifically indicated to that effect. Mastek Limited does not accept 
>any responsibility or liability for it. This e-mail and attachments (if any) 
>transmitted with it are confidential and/or privileged and solely for the use of the 
>intended person or entity to which it is addressed. Any review, re-transmission, 
>dissemination or other use of or taking of any action in reliance upon this 
>information by persons or entities other than the intended recipient is prohibited. 
>This e-mail and its attachments have been scanned for the presence of computer 
>viruses. It is the responsibility of the recipient to run the virus check on e-mails 
>and attachments before opening them. If you have received this e-mail in error, 
>kindly delete this e-mail from all computers.
> 
>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> 
> --------------------------------------------------------------------
> 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]
--------------------------------------------------------------------

Reply via email to