Hi Mike,<br><br>Thanks very much, after a few minutes of staring I think I have understood your very well put answer!<br><br>If I understand you right, what is happening is:<br><br><span><font color="#0000ff" face="Courier New" size="2">Test(&nbsp;$y : y 
)<br><br style="color: rgb(0, 0, 0);"><span style="color: rgb(0, 0, 0);">This means, WHEN there is an instance of Test, assign the value of its &quot;y&quot; property to $y</span><br style="color: rgb(0, 0, 0);"><br style="color: rgb(0, 0, 0);">
<span style="color: rgb(0, 0, 0);">AND</span><br style="color: rgb(0, 0, 0);"><br style="color: rgb(0, 0, 0);"><span style="color: rgb(0, 0, 0);">WHEN there is an instance of Test where it&#39;s &quot;x&quot; property is equal to $y + 1</span><br style="color: rgb(0, 0, 0);">
<br style="color: rgb(0, 0, 0);"><span style="color: rgb(0, 0, 0);">THEN fire.</span><br></font></span><br><br>I think I understand that. I am going to need to do this with some pretty complicated formulae, containing up to 8 different variables. I have a fixed data set and need to find certain patterns in them based on the formulae. I have most of the program figured out, my only trouble is expressing my formulae in the correct syntax. I will try to extend this principle you have explained to me and hope it can cope with the extra complication... unless there would be a better way to achieve this?<br>
<br>I am really sorry but I am totally new to drools - but am committed to using it on a project so I guess I&#39;m going to get to know it pretty well :-)<br><br>I read briefly that one can define a DSL, I might look at this eventually to build an easier mechanism for expressing my formulae - if that can be achieved using a DSL.<br>
<br>Can the whole rule be defined in Groovy/Java - if so I might be easier doing that. I have so much work to do!<br><br><br>many thanks<br><br>Richard<br><br><br><br><div class="gmail_quote">2008/5/2 Anstis, Michael (M.) &lt;<a href="mailto:manstis1@ford.com">manstis1@ford.com</a>&gt;:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">



<div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2">Hi Richard,</font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2"></font></span>&nbsp;</div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2">The &quot;when&quot; section matches fact (object) patterns, so your 
requirement could be written as:-</font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2"></font></span>&nbsp;</div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Courier New" size="2">when there is a Test Fact &#39;A&#39; and another Test Fact &#39;B&#39; 
where &quot;the &#39;x&#39; property of&nbsp;&#39;A&#39;&quot; equals &quot;the &#39;y&#39; property of&nbsp;fact &#39;B&#39; 
plus 1&quot;&nbsp;then.....</font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Courier New" size="2"></font></span>&nbsp;</div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2">This would become:-</font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2"></font></span>&nbsp;</div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Courier New" size="2">rule &quot;Rule 1&quot;</font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Courier New" size="2">when</font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Courier New" size="2">&nbsp;&nbsp;&nbsp;&nbsp;Test(&nbsp;$y : y 
)</font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Courier New" size="2">&nbsp;&nbsp;&nbsp;&nbsp;Test(&nbsp;x == ($y + 1) 
)</font></span></div><div class="Ih2E3d">
<div dir="ltr" align="left"><span><font color="#0000ff" face="Courier New" size="2">then</font></span></div>
<div dir="ltr" align="left"><span><font face="Courier New">&nbsp;&nbsp;&nbsp; <font color="#0000ff" size="2">System.out.println(&quot;Rule 1 matches&quot;);</font></font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Courier New" size="2">end</font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font></span></div>
</div><div><span></span><font face="Arial"><font color="#0000ff"><font size="2">By&nbsp;default&nbsp;both&nbsp;patterns&nbsp;can&nbsp;match&nbsp;the&nbsp;same&nbsp;object,&nbsp;so&nbsp;test&nbsp;data:-</font></font></font></div>
<div><font face="Arial"><font color="#0000ff"><font size="2"></font></font></font>&nbsp;</div>
<div><font><font><font color="#0000ff" face="Courier New" size="2"><span>A : x = 1, y = 1</span></font></font></font></div>
<div><font><font><font color="#0000ff" face="Courier New" size="2"><span>B : x = 2, y = 1</span></font></font></font></div>
<div><font><font><font color="#0000ff" face="Arial" size="2"><span></span></font></font></font>&nbsp;</div>
<div><font><font><font color="#0000ff" face="Arial" size="2"><span>Will cause the rule to activate 
twice:-</span></font></font></font></div>
<div><font><font><font color="#0000ff" face="Arial" size="2"><span></span></font></font></font>&nbsp;</div>
<div><font><font><font color="#0000ff" face="Courier New" size="2"><span>A and B</span></font></font></font></div>
<div><font><font><font color="#0000ff" face="Courier New" size="2"><span>B and B</span></font></font></font></div>
<div><font><font><font color="#0000ff" face="Arial" size="2"><span></span></font></font></font>&nbsp;</div>
<div><font><font><font color="#0000ff" face="Arial" size="2"><span>With kind regards,</span></font></font></font></div>
<div><font><font><font color="#0000ff" face="Arial" size="2"><span></span></font></font></font>&nbsp;</div>
<div><font><font><font color="#0000ff" face="Arial" size="2"><span>Mike</span></font></font></font></div>
<div><font color="#0000ff" face="Arial" size="2"></font><br></div>
<blockquote style="margin-right: 0px;">
  <div dir="ltr" align="left" lang="en-us">
  <hr>
  <font face="Tahoma" size="2"><b>From:</b> <a href="mailto:rules-users-bounces@lists.jboss.org" target="_blank">rules-users-bounces@lists.jboss.org</a> 
  [mailto:<a href="mailto:rules-users-bounces@lists.jboss.org" target="_blank">rules-users-bounces@lists.jboss.org</a>] <b>On Behalf Of </b>Richard 
  Bremner<br><b>Sent:</b> 02 May 2008 08:53<br><b>To:</b> 
  <a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br><b>Subject:</b> [rules-users] newbie question 
  on &quot;when&quot; condition syntax<br></font><br></div><div><div></div><div class="Wj3C7c">
  <div></div>Hi, <br><br>say I have a class with two fields, x and y: 
  <br><br>public class Test { <br>&nbsp; &nbsp; int x = 1; <br>&nbsp; &nbsp; int 
  y = 2; <br><br>&nbsp; &nbsp; getters/setters... <br>} <br><br><br>I would like 
  a rule which fires when y = x + 1 <br><br>my initial thought would be 
  something like: <br><br>rule &quot;Rule 1&quot; <br>&nbsp; &nbsp; &nbsp; &nbsp; 
  <br>&nbsp; &nbsp; &nbsp; &nbsp; when <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
  &nbsp; &nbsp; &nbsp; test : Test (y == x + 1) <br>&nbsp; &nbsp; &nbsp; &nbsp; 
  then <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
  System.out.println(&quot;Rule 1 matches.&quot;); <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
  &nbsp; &nbsp; &nbsp; <br>end <br><br><br>but this is invalid syntax and I can 
  not find any examples of such a rule. I&#39;m doing my best but reading the manual 
  etc. I&#39;m struggling with the syntax here and can&#39;t figure it out.<br><br>any 
  help really appreciated! </div></div></blockquote></div>
<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>
<br></blockquote></div><br>