Hi Ryan,
It's funny how questions tend to come in groups. I just answered this
same question from someone else in private email this morning. Here's
part of that reply:
The last paragraph of section 2.8.1 of the Jess manual (6.0a8) says:
"If you match to a defglobal with a pattern like (foo ?*x*), the match
will only consider the value of the defglobal when the fact is
asserted. Subsequent changes to the defglobal's value will not
invalidate the match - i.e., the match does not reflect the current
value of the defglobal, but only the value at the time the matching
fact was asserted."
So this is not a bug, but a feature. Patterns are evaluated when a
fact is asserted; they are not reevaluated again unless the fact is
retracted and reasserted. What you need to do is use facts instead of
defglobals for your registers.
I think Withers, Ryan(STL) wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> Hello,
>
> A quick question about defglobals, I have rules that via a defined
> salience value are known to fire before the rule below. When they fire I
> bind certain values to defglobals that I have called registers. One example
> of the register is ?*register4* below which is populated before this rule
> with a programId I need to be looking for. However, when I try to access a
> defglobal on the LHS of any rule (I've tried with a couple), the test does
> not evaluate the way I think it should. Is there a way I can get access to
> a defglobal on the LHS of a rule? Any help advice would be appreciated.
>
> Sincerely,
>
> Ryan
>
> (defrule enrolling-physician-on-order-rule "No Enrolling physician found,
> please enter one." (enrollment_detail (customer_id ?customer_id)(program_id
> ?program_id)(enrolling_physician_id ?enrolling_physician_id))
> (test (eq ?program_id ?*register4*))
> => (if (or (and (eq ?*register7* ?customer_id)
> (eq ?*register6* ?enrolling_physician_id)) (eq ?*register6* ?customer_id))
> then else
> (assert (testResults (failureMsg
> (str-cat "Patients must have their enrolling physician place the order,
> patient may need to be reenrolled under a new physician. " ?customer_id " "
> ?program_id " " ?enrolling_physician_id " "))))))
>
> ---------------------------------------------------------------------
> 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]
---------------------------------------------------------------------