<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">You could try assigning $item to a local variable and then using that within the for loop?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">Thomas<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;">From:</span></b><span style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;"> rules-users-bounces@lists.jboss.org [mailto:rules-users-bounces@lists.jboss.org]
<b>On Behalf Of </b>Martin A<br>
<b>Sent:</b> 11 January 2012 10:02<br>
<b>To:</b> Rules Users List<br>
<b>Subject:</b> Re: [rules-users] For loop inside a modify block problem<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">hi Michael,<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal">All of the fields are public, however they are properties of a super class of Item. I tried with getters, doesn't work either way.&nbsp;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Still getting: 'no such identifier : $item'. When I remove the for loop, it goes ok, so I think it messes up things.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal">Best regards,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">Martin<o:p></o:p></p>
<div>
<p class="MsoNormal">2012/1/11 Michael Anstis &lt;<a href="mailto:michael.anstis@gmail.com">michael.anstis@gmail.com</a>&gt;<o:p></o:p></p>
<p class="MsoNormal">RHS is not DRL syntax but Java or MVEL depending on your dialect.<br>
<br>
If &quot;id&quot; is not public you should use it's getter. The same goes for &quot;quantity&quot;.<o:p></o:p></p>
<div>
<p class="MsoNormal"><br>
<br>
<span style="font-family:&quot;Courier New&quot;">when<br>
&nbsp;&nbsp;&nbsp; $item : Item(param1 != 0, param2 == 0, !(this instanceof SpecialItem))<br>
&nbsp;&nbsp;&nbsp; $gsc : SomeBusinessLogic<br>
then </span><o:p></o:p></p>
</div>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp; $gsc.doSomething($item.getId() );<br>
&nbsp;&nbsp;&nbsp; for (int i = 0; i &lt; $item.getQuantity(); i&#43;&#43;) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $gsc.doSomethingElse($item.getId() );<br>
&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; update($gsc);<br>
end</span><o:p></o:p></p>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-family:&quot;Courier New&quot;"><br>
<br>
</span><o:p></o:p></p>
<div>
<p class="MsoNormal">2012/1/11 Martin A &lt;<a href="mailto:wmlsub@gmail.com" target="_blank">wmlsub@gmail.com</a>&gt;<o:p></o:p></p>
<p class="MsoNormal">Hi, Davide,<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal">Here is how my rule looks like :<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal">when<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">&nbsp; &nbsp; $item : Item(param1 != 0, param2 == 0, !(this instanceof SpecialItem))<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">&nbsp; &nbsp; $gsc : SomeBusinessLogic<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">then&nbsp;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">&nbsp; &nbsp; $gsc.doSomething($<a href="http://item.id/" target="_blank">item.id</a>);<o:p></o:p></p>
<div>
<div>
<p class="MsoNormal">&nbsp; &nbsp; for (int i = 0; i &lt; $item.quantity; i&#43;&#43;) {<o:p></o:p></p>
</div>
<p class="MsoNormal">&nbsp; &nbsp; &nbsp; &nbsp; $gsc.doSomethingElse($<a href="http://item.id/" target="_blank"><span style="color:#1155CC">item.id</span></a>);<br>
&nbsp; &nbsp; }<br>
&nbsp; &nbsp; update($gsc);<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">end<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal">The above snippet throws an error @ i &lt; $item.quantity, and says 'no such identifier $item'...<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">I can't figure out what might be causing this.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal">Thanks<o:p></o:p></p>
</div>
<div>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<div>
<p class="MsoNormal">On Tue, Jan 10, 2012 at 10:08 PM, Davide Sottara &lt;<a href="mailto:dsotty@gmail.com" target="_blank">dsotty@gmail.com</a>&gt; wrote:<o:p></o:p></p>
<p class="MsoNormal">Did you remember to bind $item to some expression in the LHS ? Maybe you just<br>
called that &quot;item&quot; without the $ :)<br>
Davide<br>
<br>
(the original &quot;modify&quot; syntax is still wrong anyway)<br>
<span style="color:#888888"><br>
--<br>
View this message in context: <a href="http://drools.46999.n3.nabble.com/rules-users-For-loop-inside-a-modify-block-problem-tp3648460p3648718.html" target="_blank">
http://drools.46999.n3.nabble.com/rules-users-For-loop-inside-a-modify-block-problem-tp3648460p3648718.html</a><br>
Sent from the Drools: User forum mailing list archive at Nabble.com.</span><o:p></o:p></p>
<div>
<div>
<p class="MsoNormal">_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">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><o:p></o:p></p>
</div>
</div>
</div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
</div>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">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><o:p></o:p></p>
</div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><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><o:p></o:p></p>
</div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
</div>
</div>
<br>
<hr>
<font face="Arial" color="Gray" size="1"><br>
**************************************************************************************<br>
This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmaster@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data
 may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary.<br>
<br>
NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00<br>
**************************************************************************************<br>
</font>
</body>
</html>