[rules-users] How to get value of global variable from one rule to another

Edson Tirelli tirelli at post.com
Thu Jun 14 10:18:28 EDT 2007


   Globals are intended to provide a way to pass values in and out of the
engine. Not for reasoning and exchange of values between rules.
   Values that are changed by rules and are reasoned over are clearly facts
of your domain and should be modeled as such.

    []s
    Edson

2007/6/14, Alexander Komissarov <aleks.komissarov at gmail.com>:
>
> Hello,
>
> Please give me advice for best way storing global variables.
>
> global java.lang.Integer res;
> global java.lang.Integer res2;
> ...
>
> I've several number of rules. One rule has variable initialization e.g.:
>
> ...
> rule "AmountsAreNotNull" salience 20
>     when
>         < conditions >
>     then
>        ...
>         res = new Integer(a.compareTo(new BigDecimal(25)));
>         res = (res == -1)?0:res;
>         res = (res == -1)?0:res;
>         res2 = new Integer(a.compareTo(b));
>         res2 = (res2 == -1)?0:res2;
>        ...
> end
>
> The values of these variables are proper and equal 1
>
> Then next rule has comparing for res|res2 values, but they have lost their
> values (res == null and res2 == null)
>
> rule "CompareValues" salience 10
>     when
>         res:Integer(intValue == 0)
>         res2:Integer(intValue == 0)
>         result:List()
>     then
>         result.add(Boolean.TRUE);
> end
>
> What decision you can advise me to save variables value between rules?
> Thanks.
> ____________________
> Regards,
> Komissarov Alexander
> mail: aleks.komissarov at gmail.com
> icq: 239128267
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>


-- 
  Edson Tirelli
  Software Engineer - JBoss Rules Core Developer
  Office: +55 11 3529-6000
  Mobile: +55 11 9287-5646
  JBoss, a division of Red Hat @ www.jboss.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20070614/98a9f826/attachment.html 


More information about the rules-users mailing list