Yes, that's one good way to do it, using a router. From Jess:

Jess> (bind ?sw (new java.io.StringWriter)) 
<External-Address:java.io.StringWriter> 
Jess> (defrule foo (foo) => )  
foo
Jess> (assert (foo))
<Fact-0>
Jess> (watch rules)
TRUE
Jess> (call (engine) addOutputRouter WSTDOUT ?sw)
(run)
(printout t * ?sw * crlf)
*Jess>
 FIRE 1 foo f-0
1
Jess> *

Note how the prompts disappear because they're going to WSTDOUT,
too. You could use a FileWriter instead of a StringWriter, if you
want. 

Another way altogether (a better way, perhaps) to do this would be to
use the JessListener interface. See manual section 4.10 for an example.




I think Kami ROUSSEAU wrote:
[Charset Windows-1252 unsupported, filtering to ASCII...]
> Hello,
> 
> When rules fire, is it possible to put their <rule-name> + <trigger-fact-id>
> + <trigger-fact.toString()> in a data structure (Vector or List) ?
> 
> Maybe it can be done by using (watch "rules") after somehow redirecting
> WSTDOUT to the data structure, but I am not sure how to do this.
> Is it possible to create a PrintWriter that will add an entry to a data
> structure everytime it is flushed?
> 
> -Kami ROUSSEAU
> 
> ---------------------------------------------------------------------
> 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