Hi,

I believe your understanding of salience is correct, in that if two
rules are both activated and one has a higher salience, that one will
be fired first. But the rules below are not well-formed. The first one
tries to call a non-existent function "defglobal". (defglobal) is a
"construct", not a function, so you can't call it that way. If this
rule fires, you'll get an exception to the effect that defglobal is an
unimplemented function. 

If you really need to define a defglobal on a rule RHS, then you can
use (build) to create the construct on the fly:

  (build (str-cat "(defglobal ?*program_id* = " ?programId ")"))

but I can't think of a reason why this is better than simply having
the rule set the value of a defglobal that already exists.

I've been asked "what's the difference between a construct and
function?" The non-technical answer is that if it's listed in manual
chapter 8, it's a function; otherwise it's not. A slightly more
technical answer is that constructs are handled specifically by the
parser. 

I think Withers, Ryan(STL) wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> Hello,
> 
>   This is in reference to the message below, the exact text of my rules
> follows.
> 
> -Ryan
> 
> (defrule accepting-enrollment-rule "Please enter valid program."
>   (declare (salience 10000))
>   (Program (stop_time ?stop_time)(programId ?programId))
>   =>
>   (if (< 0 (compare-datetime ?stop_time)) then
>     (defglobal ?*program_id* = ?programId) else
>   (assert (testResults (failureMsg "Program is not accepting orders
> anymore.")))
> ))
> 
> (defrule enrollment-validation "Valid enrollment record not found."
>   (enrollment_detail (customer_id ?customer_id)(program_id ?program_id)
>     (stop_time ?stop_time))
>   (test (eq program_id *program_id*))
>   =>
>   (if (> 0 (compare-date ?stop_time)) then (assert (testResults (failureMsg
> "Enr
> ollment in program has expired, user must reenroll.")))))
> 
> -----Original Message-----
> From: Withers, Ryan(STL) [mailto:[EMAIL PROTECTED]] 
> Sent: Tuesday, June 26, 2001 5:33 PM
> To: [EMAIL PROTECTED]
> Subject: JESS: Eval Salience
> 
> 
> Hello,
> 
>   I am trying to evaluate rules in a certain order declaring a salience
> value like so (declare (salience 10000)), I have two rules defined one with
> a salience value of -5000 and one with a value of 10000.  I would assume the
> one with the salience of 10000 would fire first followed by the one declared
> -5000.  The reason I want firing precedence is to be able to use a global
> variable defined by the rule that should be firing first in the rule that is
> firing second. 
> 
>   I am using Jess5.1, if anyone knows of anything that would help me figure
> out how to handle this situation I would appreciate it.
> 
> Sincerely,
> 
> Ryan
> 
> ---------------------------------------------------------------------
> 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]
> ---------------------------------------------------------------------
> 
> ---------------------------------------------------------------------
> 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