Hello everyone,
I am searching for a way of erasing specifed defrules from the engine
when the user has decided not to continue : (Essentially, I wish to
leave only those defrules whose names commence with the phrase
'main').
As I am unfamiliar with the workings of Jess' Java reflection
capabilities, I have scavanged some code previously sent to the Jess
Users mailing list (the purpose of which was to save all defrules to a
specified file) and come up with the following.
(defrule main_clean-up
"Erasing unwanted rules"
?fact1 <- (continue no)
=>
(retract ?fact1)
(bind ?list (call (engine) listDefrules))
(while (call ?list hasMoreElements)
(bind ?rule (call ?list nextElement))
(bind (?name (sub-string 1 4 ?rule)))
(if (neq (?name main))
(undefrule ?rule))))
Unfortunately this does not seem to work correctly.
Could someone please explain why this is the case and how the code
could be rectified.
Many thanks,
Michael D.M. Ward
---------------------------------------------------------------------
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]
---------------------------------------------------------------------