<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
This list is for discussions on the development of the drools project,
for help on how to use drools please use the user mailing list.<br>
<br>
Thank you.<br>
<br>
Mark<br>
Alexander Komissarov wrote:
<blockquote
 cite="mid:8c1024150706120515q5eaa810cj9dde50641ec4b48c@mail.gmail.com"
 type="cite">Hello,<br>
  <br>
Please give me advice for best way storing global variables.<br>
  <br>
global java.lang.Integer res;<br>
global java.lang.Integer res2;<br>
...<br>
  <br>
I've several number of rules. One rule has variable initialization e.g.:<br>
  <br>
...<br>
rule "AmountsAreNotNull" salience 20<br>
&nbsp;&nbsp;&nbsp; when<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt; conditions &gt;<br>
&nbsp;&nbsp;&nbsp; then<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; ...<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; res = new Integer(a.compareTo(new BigDecimal(25)));<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; res = (res == -1)?0:res;
  <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; res = (res == -1)?0:res;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; res2 = new Integer(a.compareTo(b));<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; res2 = (res2 == -1)?0:res2;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ...<br>
end<br>
  <br>
The values of these variables are proper and equal 1<br>
  <br>
Then next rule has comparing for res|res2 values, but they have lost
their values (res == null and res2 == null)
  <br>
  <br>
rule "CompareValues" salience 10<br>
&nbsp;&nbsp;&nbsp; when<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; res:Integer(intValue == 0)<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; res2:Integer(intValue == 0)<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; result:List()<br>
&nbsp;&nbsp;&nbsp; then<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; result.add(Boolean.TRUE);<br>
end<br clear="all">
  <br>
What decision you can advise me to save variables value between rules?<br>
Thanks.<br>
____________________<br>
Regards,<br>
Komissarov Alexander<br>
mail: <a moz-do-not-send="true"
 href="mailto:aleks.komissarov@gmail.com">aleks.komissarov@gmail.com
  </a><br>
icq: 239128267<br>
  <br>
  <pre wrap="">
<hr size="4" width="90%">
_______________________________________________
rules-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/rules-dev">https://lists.jboss.org/mailman/listinfo/rules-dev</a>
  </pre>
</blockquote>
<br>
</body>
</html>