Thanks a lot for the answers!!!
I decided to use queries:
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);
while (e.hasNext())
{
Token t = (Token) e.next();
Fact f = t.fact(1);
tag = f.get(2).stringValue(null);
text = f.get(4).stringValue(null);
}
...
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);
If you know that the query returns only one result, is there a way not to use an
Iterator and get the value directly?
Vincent
>hi,
you can write a User function in java and load it in jess.
In Jess you can have a rule like this:
(defrule rule
?factId <- (Tag (ParentID 0))
=>
(myUserFunction ?factId))
>From the call method of the user function, you can get the Fact object from the
>FactIdValue.
I hope this works for you.
Shankar
[EMAIL PROTECTED] schrieb am 29.05.02:
> I think Vincent Wolowski wrote:
> [Charset iso-8859-1 unsupported, filtering to ASCII...]
>
> > I use the following rule:
> >
> > rete.executeCommand("(defrule getFactIDofRootElement"+
> > "(Tag (ParentID 0))"+
> > "=>"+
> > "(?factID <- (Tag (ParentID 0))))");
> >
> > If I use the return value, the value is true.
>
> Well, yes. Defining a rule doesn't do anything; you'd have to run the
> rule. Then you'd have to have the rule -do- something with the result,
> to make it available to you in Java. You could use the store and fetch
> functions; see manual section 4.4.4. The rule calls store, and then
> you call fetch in Java. If you store ?factID, the Java object you
> fetch will be a jess.FactIdValue.
>
> It would be more appropriate, though, to use a defquery instead of a
> rule here; see manual section 2.9.
>
> ---------------------------------------------------------
> 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]
--------------------------------------------------------------------