I think that Jing Mei wrote:
>>Does it mean that it is not permitted to write the results of a rule to
the file
>>router? Or just I have done some stupid mistakes?

Hi Jing Mei,

If you look at your code, you are opening and closing the router before the
rule engine is run!

;; Here you are resetting the working memory
(reset)

;; Now, you are opening the file
(open "out.txt" mo "w")

;; Then you define a rule
(defrule fail
   (test (< 2 3))
    =>
  (printout mo "fail" crlf)
)
;;Now, you're closing the router!
(close mo)

;; By the time you run Jess, there
;; is nowhere to send the output!  :-D
(run)

Try this code instead...

;;========= printfile.clp ===========
(clear)
(watch all)

;; Open a writer to the file
;; UNIX, use your "out.txt" for the file
(open "C:/out.txt" file "w")

;; A rule that fires and prints to a file
(defrule test-rule
  (test (< 2 3))
  =>
  (printout file "This rule did fire!" crlf))

;; Reset working memory
(reset)

;; Run Jess
(run)

;; Close the file when all rules have fired
(close file)
;;=====================================

This code writes the file as expected.

Cheers,
Jason
----------------------------------------------
 Jason Morris - Assistant Moderator
 Jess Listserver - [EMAIL PROTECTED]
 email: [EMAIL PROTECTED]
 www.morristechnicalsolutions.com
 fax/phone: 503.692.1088
------------------------



--------------------------------------------------------------------
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