|
View:
New views
5 Messages
—
Rating Filter:
Alert me
|
|
|
|
|
|
Re: JESS: global variable comparisons with = and <>Hye, I have read your message and I looked a little in my documentation about Jess. In the book Jess in Action the author has written about Matching global variables the followings: "If you match to a defglobal with a pattern like (score ?*x*), the match only considers the value of the defglobal when the fact is first asserted. Subsequent changes to the defglobals value will not invalidate the matchif the rule was activated based on the value of the defglobal, it stays activated even if the defglobals value changes. The match does not reflect the current value of the defglobal, but only the value at the time the matching fact was asserted." I hope you will find a solution for your problem. Ana Tanasescu
Never miss a thing. Make Yahoo your homepage. |
|
|
Re: JESS: global variable comparisons with = and <>That's right. More generally, the point is that pattern matching is
driven by assertions, retractions, and modifications to working memory -- changes to facts. Changing a defglobal will not cause a match to be reconsidered. But if there were a fact being matched *before* the "test" pattern, then when that fact changed, the global would be re-checked. On Mar 29, 2008, at 9:10 AM, ANA TANASESCU wrote: > Hye, > > I have read your message and I looked a little in my documentation > about Jess. > In the book Jess in Action the author has written about Matching > global variables the followings: > > "If you match to a defglobal with a pattern like (score ?*x*), the > match only considers the value of the defglobal when the fact is > first asserted. Subsequent changes to the defglobal’s value will > not invalidate the match—if the rule was activated based on the > value of the defglobal, it stays activated even if the defglobal’s > value changes. The match does not reflect the current value of the > defglobal, but only the value at the time the matching fact was > asserted." > > I hope you will find a solution for your problem. > > Ana Tanasescu > > Never miss a thing. Make Yahoo your homepage. --------------------------------------------------------- Ernest Friedman-Hill Informatics & Decision Sciences Phone: (925) 294-2154 Sandia National Labs FAX: (925) 294-2234 PO Box 969, MS 9012 ejfried@... Livermore, CA 94550 http://www.jessrules.com -------------------------------------------------------------------- To unsubscribe, send the words 'unsubscribe jess-users you@...' in the BODY of a message to majordomo@..., NOT to the list (use your own address!) List problems? Notify owner-jess-users@.... -------------------------------------------------------------------- |
|
|
Re: JESS: global variable comparisons with = and <>Hello again, I followed Ernest's advice and I have modified your program. The only thing that I have done is that I put the test CE after the pattern matching. Here it is the modified program: (reset) (defglobal ?*currentOpenToolbar* = MasterToolbar) (deftemplate toDisplayToolbar (slot toolbar) (slot visible)) (defrule 1stTime (toDisplayToolbar (toolbar ?toolbar) (visible ?v&:(eq ?v TRUE))) (test (= ?*currentOpenToolbar* MasterToolbar)) => (printout t "1st Time" crlf) (bind ?*currentOpenToolbar* ?toolbar) (printout t "?*currentOpenToolbar is now " ?*currentOpenToolbar* crlf)) (defrule SubsequentTime (toDisplayToolbar (toolbar ?toolbar) (visible ?v&:(eq ?v TRUE))) (test (<> ?*currentOpenToolbar* MasterToolbar)) => (printout t "Not1stTime"
crlf) (bind ?*currentOpenToolbar* ?toolbar) (printout t "?*currentOpenToolbar is now " ?*currentOpenToolbar* crlf)) (watch all) (assert (toDisplayToolbar (toolbar PenToolbar) (visible FALSE)))
(run) (assert (toDisplayToolbar (toolbar PenToolbar) (visible TRUE))) (run) (assert (toDisplayToolbar (toolbar Anothertoolbar) (visible TRUE)))
(run) Best regards, Ana Tanasescu
OMG, Sweet deal for Yahoo! users/friends: Get A Month of Blockbuster Total Access, No Cost. W00t |
|
|
Re: JESS: global variable comparisons with = and <>It works now as it should! /Chirag On 29/03/2008, ANA TANASESCU <atanasescuro@...> wrote:
|
| Free Forum Powered by Nabble | Forum Help |