Hi Michael,

There isn't a built-in function for saving all rules, but it's easy to
write a deffunction which does this using Jess's Java reflection capabilities.

(deffunction rules-to-file (?filename)
  "Pretty-print all defined rules to a file"
  (open ?filename rtf-file w)                    ;; Open the file
  (bind ?e (call (engine) listDefrules))         ;; get Enumeration of all rules
  (while (call ?e hasMoreElements)               ;; for each element of Enumeration
    (bind ?r (call ?e nextElement))              ;; fetch the element
    (printout rtf-file (call ?r toString) crlf)) ;; print Defrule.toString() to file
  (close rtf-file))

You can then just use (batch) to read the file in. Precisely similar
technique can be used for deftemplates,d effacts, etc.

I think M Ward wrote:
> 
> Hello,
> 
> I am a newcomer to the field of Jess and so would appreciate some
> guidance on the following enquiry.
> 
> I am aware that deffacts can be saved and and loaded using the 
> save-facts and load-facts comands respectively.   Is there a similar
> command that allows for defrules to be saved to and loaded from a
> named file?  
> 
> Many thanks,
> 
> Michael D.M. Ward


---------------------------------------------------------
Ernest Friedman-Hill  
Distributed Systems Research        Phone: (925) 294-2154
Sandia National Labs                FAX:   (925) 294-2234
Org. 8920, MS 9214                  [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