<br> There are several ways of doing that, and some where even mentioned by the other users. One easy way is to simply use "accumulate":<br><br>rule "update amount"<br> no-loop<br>when<br> $f : Fact( name == "amount" )<br>
Number( $total : doubleValue ) from accumulate(<br> Charge( $amt : amount ),<br> sum( $amt ) )<br>then<br> modify( $f ) { setAmount( $total ) } <br>end<br><br> []s<br> Edson<br><br><div class="gmail_quote">
2008/11/4 Dan Seaver <span dir="ltr"><<a href="mailto:dan.seaver@ge.com">dan.seaver@ge.com</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
I'm trying to find a good technique for updating specific facts in working<br>
memory. What I'm currently doing is something like this:<br>
<br>
Rule "Update Amount"<br>
when<br>
amountFact : Fact(name == "Amount")<br>
charge : Charge()<br>
then<br>
Double amount = amountFact.getAmount();<br>
Double chargeAmount = charge.getAmount();<br>
amountFact.setAmount(amount + chargeAmount);<br>
update(amountFact);<br>
end<br>
<br>
The update statement causes an infinite loop.<br>
I tried using no-loop, which works if there is 1 charge, but not if there<br>
are more than one.<br>
<br>
Any help with solutions or strategies would be much appreciated.<br>
<font color="#888888">--<br>
View this message in context: <a href="http://www.nabble.com/Chart-notation%2C-update%2C-and-infinite-loops-tp20327483p20327483.html" target="_blank">http://www.nabble.com/Chart-notation%2C-update%2C-and-infinite-loops-tp20327483p20327483.html</a><br>
Sent from the drools - user mailing list archive at Nabble.com.<br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</font></blockquote></div><br><br clear="all"><br>-- <br> Edson Tirelli<br> JBoss Drools Core Development<br> JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>