Thanks a lot for your advice and the improvement of my code.
I used deftemplate and deffacts:
(deftemplate productoffer
(slot product1)
(slot product2)
(slot product3))
(deffacts productvalue
(productoffer (product1 A) (product2 B) (product3 C)))
I have the following question:
Is it right, to get each slot value in Jess, the only way is to use fact-slot-value -
foreach and nth$ are used for multifields?
Vincent
[EMAIL PROTECTED] schrieb am 31.05.02:
> I think Vincent Wolowski wrote:
> > If you know that the query returns only one result, is there a way not to use an
>Iterator and get the value directly?
> >
>
> No, but I can simplify your code in a couple of ways.
>
> >
> > String query = "(defquery elementSearch (Tag (ElementID "+elementID+") ParentID
>"+parentID+")))";
> > r.executeCommand(query);
> > r.store("RESULT2", r.runQuery("elementSearch", new ValueVector()));
> > Iterator e = (Iterator) r.fetch("RESULT2").externalAddressValue(null);
>
> Don't know why you're storing this result, only to fetch it in the
> next line. Why not just replace the two lines above with:
>
> Iterator e = r.runQuery("elementSearch", new ValueVector());
> ...
>
> > r.executeCommand("(defquery childElementCount (Tag (ParentID "+elementID+")))");
> > r.executeCommand("(bind ?n (count-query-results childElementCount))");
> > Value v = (r.getGlobalContext()).getVariable("n");
> > number = v.intValue(context);
>
> Not sure why you're using the variable "n". What's wrong with just
> doing this:
>
> number = r.executeCommand("(count-query-results childElementCount)").intValue(null);
>
> ---------------------------------------------------------
> 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]
> --------------------------------------------------------------------
>
________________________________________________________________
Keine verlorenen Lotto-Quittungen, keine vergessenen Gewinne mehr!
Beim WEB.DE Lottoservice: http://tippen2.web.de/?x=13
--------------------------------------------------------------------
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]
--------------------------------------------------------------------