I think it would be best if you can set the global variables up front, before asserting anything. Also, if a global variable is to be used in the LHS of a rule, its values should not really change for the life of that working memory.
Secondly, global variables can be used in the RHS of a rule to return values etc, no issues with that. On 4/8/06, Russ Egan <[EMAIL PROTECTED]> wrote: > > I've got a global variable, which I refer to in an eval() , but the eval() > always just sees null. > > I assert all my facts into WM /before/ I set the global variable, so I > understand > that initially, the variable will be null when the condition is first > evaluated. > But after I set the global variable, I assert additional facts, which > trigger > other conditions of that rule: > > rule "Create block rules for unauthorized resources in same network" > when > $r : Resource() > not AuthorizedResource(resource == $r) > eval (Tester.doNetworksIntersect($p, $r)) > then > BlockRule block = new BlockRule(); > block.resource = $r; > assert(block); > end > > The "$p" in the eval is the global variable. I create new > AuthorizedResource > objects after I set the global, so I figured the rule would be > re-evaluated, > the eval() along with it. Sorry for lack of knowledge, I'm completely new > to rule's engines, and still don't fully understand how Rete works. Is > the > result of the eval() cached initially and never re-evaled? If so, how are > eval() blocks ever activated again? Is that determined by the fact > bindings > which are used (like when $r is modified, that activates the eval() block > since r$ is referred to inside it)? Thanks. > > > >
