Hi,

There are several things wrong here.

First, you need to use a defglobal if you want a variable that can be
shared between rules. I believe the original poster of this suggestion
did so. ?ht is a local variable at the command prompt and can't be
accessed from rules. See manual section 2.3.1 about defglobals.

Second, your first executeCommand() call below uses the wrong syntax
for (bind) - there should be no equals sign.

Third, that same call contains two function calls - executeCommand
will ignore the second one.

Fourth, if the rule CheckDiscount-1 fires twice or more, the previous
results will be overwritten since you reuse the same Hashtable keys.

I think Matteo Melideo wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> Hi All,
> 
> I am always having problem with a rules that has to return me more than one value. I 
>have thought that perhaps the best thing to do to manage them was to use the 
>java.util.Hashtable. Just in case I prefer to show you my code.
> 
> Here it is:
> 
> ...
> 
> r.executeCommand ("(bind ?ht = (new java.util.Hashtable)) (store RESULT ?ht)");
> 
> r.executeCommand("(defrule CheckDiscount-1 " +
> 
>                  " (prodotto ?x) " +
> 
>                  " (utenti (id ?y) (scelta ?x)) " +
> 
>                  " => " +
> 
>                  " (call ?ht put \"key1\" ?y))" + 
> 
>                  " (call ?ht put \"key2\" ?x))"); 
> 
> r.run();
> 
> Hashtable ht = (Hashtable)r.fetch("RESULT").externalAddressValue(null);
> 
> for (int y= 1; y < ht.size(); y++)
> 
> System.out.println("Il Sig. Tizio con Num. Ord " + (Integer)ht.get("key1") + "ha 
>ottenuto 4 scatolette di " +                         (String)ht.get("key2") + " al 5% 
>di sconto");
> 
> The message error returned at run time is this one:
> Jess reported an error in routine call while executing (call ?ht put "key2" ?x).
> 
> Message: No method named 'put' found in class java.lang.String.
> 
> Program text: ( call ?ht put "key2" ?x ) at line 0.
> 
> ...
> 
> I thank all of you in advance for the help and apologize for the disturb.
> 
> Bye 
> 
> -- 
> Matteo Melideo  
> Direct Phone: +39 06 44741145 - Operator: +39 06 4474111
> Engineering SpA - R&D Lab -, Fax: +39 06 4465981
> Viale del Castro Pretorio, 116 E-mail: [EMAIL PROTECTED] or [EMAIL PROTECTED]
> 00184 Roma - Italy
> --
> 



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