I'm sorry this is so hard to understand. The query stuff really
doesn't have a proper Jess API. When I first put queries in during 5.0
development, I asked for user suggestions as to what a good API would
look like, and I didn't get any. It's stayed the same ever since.

In any event, the query example in Jess is followed by basically the
same code in Java, but in the Java code you can see a bit better
what's going on (given that you know Java, of course!)

The elements returned by the Enumeration ?e are jess.Token
objects. Each Token represents one set of facts that matched the
query. There are always at least two facts in each Token. The first
fact is always the "query-trigger" fact -- the corresponding pattern
is added to defqueries by Jess. This fact is at index 0 within the
Token. Therefore the first pattern you write within a query is matched
by the fact at index 1. The fact() method of the jess.Token class
accepts an integer argument and returns the corresponding jess.Fact
object, so (call ?page fact 1) returns the jess.Fact that matches the
first pattern in your query.

Now, if you want to retract that jess.Fact object, there are several
ways to do it, and (and this is important) there are differences
between how you can do it in Jess 5 and in Jess 6. Note that the
manual shipped with each version of Jess is appropriate for that
version only, and the manual on the web site itself is for version 5
and some of the examples will -not- work in Jess 6. In general, use
the manual that you download with your software.

Anyway, to retract ?page in Jess 5, you can either do

   (call (engine) retract ?page)

or

   (retract (call ?page getFactId))

In Jess 6, the first version will work, but the second won't. On the
other hand, in Jess 6 you can say

    (retract ?page)

and that will work fine.

One more thing: I'm rather proud of the fact that every code sample in
the Jess manual, Java ones and Jess ones alike, is verified as part of
the Jess functional test suite. When a version of Jess ships, I know
beyond a shadow of a doubt that every single code example works
exactly as shown. Therefore you can be confident that if an example
-doesn't- work, you're doing something differently than the manual
indicates. 


I think Matt Bishop wrote:
> I have a query that generates an enumeration of facts.  I am trying to get
> the fact from the enumeration, but I am not sure what I am getting.  the
> code I am using is this:
> 
> (bind ?page (call ?e nextElement))
> 
> Then, in the next statement, I try to retract this fact:
> 
> (retract (call ?page fact 1))  ;copied this out of the manual. No idea what
> "fact" method is.
> 
> 
> Which gives me an error:
> 
>  Message: No overloading of method 'findFactByID' in class jess.Rete I can
> call with these arguments: (call (engine) findFactByID ?__fact-id).
> 
> 
> If I try to just retract the ?page object with (retract ?page) I get a
> ClassCastException while executing ( retract ?page )
> 
> What exactly is ?page ?  If I print it out, it displays "<Fact-1>"
> 
> > ______________________________________________
> > Matt Bishop - Engineering Manager, UpFront
> > 
> > We're Growing - http://www.scenicsoft.com/jobs 
> 
> ---------------------------------------------------------------------
> 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