I think [EMAIL PROTECTED] wrote: > > I'f attempting to construct a query that will iterate over all facts that > aren't > associated with a specific deftemplate. It seem to do so I need something > like the > Java instanceof operator. I was thinking of something like this: > > (defquery all-facts-that-arent-foos > ?f <- (__fact) > (test (not (instance-of ?f MAIN::foo))) > ) > > where "foo" is the deftemplate of the classes of facts I wish to ignore. > > Is there some other way of acheiving this that I might have missed? >
This seems like a good approach -- I can't think of a better way to do it. If no templates extend "foo", then instance-of could just look like (deffunction instance-of (?fact ?name) (return (eq (str-compare (?fact getName) ?name)))) If you want to allow for foo and any template that extends foo, then you can use Fact.getDeftemplate to get the Fact's template, then use Deftemplate.getName() to check the name, and getParent() to get the parent template, and walk up the tree until getParent() returns null. Look at the Java code in jess.Node1TECT.callNodeRight(), which has to do precisely this. --------------------------------------------------------- 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] --------------------------------------------------------------------