Hi,
I am using version 70b3 and I have 2 questions

-------Question 1-----------------------------------
I am having some problem with the reset command.
I have two files one LoadCompanyRegistration.clp where
I load up all the rules, templates, functions and
define modules , the second file TestFacts.clp it is
here I first (reset) the working memory and then
assert the facts. First I batch Load
CompanyRegistration.clp then TestFacts.clp from the
command line. When I batch the TestFacts.clp the
commands reset defined inside the file does not seem
to reset the working memory.


**************NOT WORKING
main>java jess.Main

Jess, the Rule Engine for the Java Platform
Copyright (C) 2005 Sandia Corporation
Jess Version 7.0b3 9/15/2005

Jess> (batch LoadCompanyRegistration.clp)
TRUE
Jess> (batch TestFacts.clp)
<Fact-8>
Jess> (batch TestFacts.clp)
FALSE
Jess>


***************File
TestFacts.clp**********************
(reset)

(assert (CashPayment (companyId 1)(id "doc1")(currency
DKK)(NominalAmount 100000)(Rate 200)))

(assert (ValuationPayment (companyId 1) (id
"doc1")(currency DKK)(NominalAmount 25000)(Rate 200)
        (DescriptionText "Min gamle bil, en Volvo
440") (PersonName "Statsaut. Revisor Grunke
Klejnesen")
                 (CPRNumber 010203-1425)))


If instead i remove the reset command form the
TestFacts.clp and call it from the command line it
works.
The output screen........................ 


*******WORKING
main>java jess.Main

Jess, the Rule Engine for the Java Platform
Copyright (C) 2005 Sandia Corporation
Jess Version 7.0b3 9/15/2005

Jess> (batch LoadCompanyRegistration.clp)
TRUE
Jess> (batch TestFacts.clp)
<Fact-8>
Jess> (reset)
TRUE
Jess> (batch TestFacts.clp)
<Fact-8>
Jess>

***************File TestFacts.clp*******************

(assert (CashPayment (companyId 1)(id "doc1")(currency
DKK)(NominalAmount 100000)(Rate 200)))

(assert (ValuationPayment (companyId 1) (id
"doc1")(currency DKK)(NominalAmount 25000)(Rate 200)
        (DescriptionText "Min gamle bil, en Volvo
440") (PersonName "Statsaut. Revisor Grunke
Klejnesen")
                 (CPRNumber 010203-1425)))


Why is it not resetting the working memory if i define
the reset in the TestFact.clp?


-------------Question 2-----------------
I also dont understand the require and provide
commands very well. I have defined a file Modules.clp
where i define my modules 

(provide ../main/Modules)
(defmodule COMPANYREGISTRATIONFAIL)
(defmodule COMPANYREGISTRATIONPASS)
(defmodule COMPANYREGISTRATIONREPORT)
(defmodule COMPANYREGISTRATIONTEXT)

When I require (require ../main/Modules) it form other
files because I assert to different module the system
complains 
It says that I am trying to redefine some module Why?
I thought these commands were used in order to work
with  different files without eclipse complaining. It
seems to me that it is actually loading these file
like a batch commands.
Can you please explain it to me?

Jess> (batch LoadCompanyRegistration.clp)
Jess reported an error in routine Agenda.addDefmodule
        while executing (require ../main/Modules)
        while executing (batch ../util/Functions.clp)
        while executing (batch
LoadCompanyRegistration.clp).
  Message: Attempt to redefine defmodule
COMPANYREGISTRATIONFAIL.
  Program text: ( batch LoadCompanyRegistration.clp ) 
at line 1.





-------------Question3------------
I also dont understand the something about the
jessListener
I wrote the following function to keep track of rules
that fire.


(import jess.JessEvent)
(import jess.JessEventAdapter)


 (call (engine) addJessListener 
      (new JessEventAdapter set-current-rule-name
(engine)))

(defglobal ?*count* = 0)
 (deffunction set-current-rule-name (?evt)
        (if (eq (get-member JessEvent DEFRULE_FIRED) (get
?evt type)) then  
            (bind ?tmpM
                (call (call (call ?evt getObject) getRule)
getModule));Get the module name where the rule just
fired
                (bind ?tmpR 
                (call (call (call ?evt getObject) getRule)
getName));Get the rule name that just fired
                (bind ?date (new Date))     
                (bind ?ISO (new String yyyy-mm-dd.hh.mm.ss))
        (bind  ?df (new SimpleDateFormat ?ISO))
        (bind ?*count* (+  ?*count* 1))          
        (assert (COMPANYREGISTRATIONREPORT::rule-fired
(order  ?*count*)(name ?tmpR)(time (call ?df format
?date))(module ?tmpM)))                 
        
        )
)


When I batch for the first time the files that include
my rules templates and functions everything is fine.
When I try to batch again or execute (clear) command
after I have already batch once I get the following
error.

Jess reported an error in routine get-member
        while executing (get-member JessEvent
DEFRULE_FIRED)
        while executing (eq (get-member JessEvent
DEFRULE_FIRED) (get ?evt type))
        while executing (if (eq (get-member JessEvent
DEFRULE_FIRED) (get ?evt type)) then (bind ?tmpM (call
(call (call ?evt getObject) get
Rule) getModule)) (bind ?tmpR (call (call (call ?evt
getObject) getRule) getName)) (bind ?date (new Date))
(bind ?ISO (new String yyyy-mm-dd
.hh.mm.ss)) (bind ?df (new SimpleDateFormat ?ISO))
(bind ?*count* (+ ?*count* 1)) (assert
(COMPANYREGISTRATIONREPORT::rule-fired (order ?*co
unt*) (name ?tmpR) (time (call ?df format ?date))
(module ?tmpM))))
        while executing deffunction
set-current-rule-name
        while executing (set-current-rule-name
<Java-Object:jess.JessEvent>).
  Message: No such class JessEvent.
TRUE


Can you tell me why and how to avoid this? The only
way I can avoid this problem it is by saving the
jessListener function in another file and load it up
only once. Do I need to use
removeJessListener(JessListener jel) and if that it is
the case how?


Thank you in advance 
Giovanni









        

        
                
___________________________________ 
Yahoo! Mail: gratis 1GB per i messaggi e allegati da 10MB 
http://mail.yahoo.it

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