<br>&nbsp;&nbsp; Natraj,<br><br>&nbsp;&nbsp; Globals were not designed to be available in functions, unless they are sent in as parameters in the way you did in your second example.<br><br>&nbsp;&nbsp; []s<br>&nbsp;&nbsp; Edson<br><br><div><span class="gmail_quote">
2007/7/2, Natraj Gudla &lt;<a href="mailto:natraj.gudla@gmail.com">natraj.gudla@gmail.com</a>&gt;:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div>Hello,</div>
<div>&nbsp;</div>
<div>I am using Drools 3.0.6. While using a global variable in a function, the compiler complains it cannot resolve the global variable name. Something like below</div>
<div>&nbsp;</div><b><font color="#960000" size="2">
<p>global</p></font></b><font size="2"> com.<strong>sample</strong>.ExampleLogger <strong>customLogger</strong>;</font><b><font color="#960000" size="2">
<p align="left">function</p></font></b><font size="2"> </font><b><font color="#960000" size="2">void</font></b><font size="2"> logMessage(String msg){</font><font size="2">
<p align="left"></p></font><font color="#808000" size="2">customLogger.logMessage(&quot;Log Message from the function&quot;);</font><font size="2">
<p>}</p>
<div></div></font>In the above code, it complains &quot;customLogger cannot be resolved&quot;. I am able to refer the global in the consequence of a rule directly. What is the problem using the reference within a function. 

<div>&nbsp;</div>
<div>On the other hand, i am able to do something like</div>
<div><strong><font color="#960000" size="2">&nbsp;</font></strong> 
<p align="left">function<font size="2"> </font><b><font color="#960000" size="2">void</font></b><font size="2"> logMessage(<font size="2">ExampleLogger custLogger,</font>String msg){</font></p><font size="2">
<p align="left"></p></font><font color="#808000" size="2"><font size="2">
<p>custLogger.logMessage(msg+</p></font><font color="#008000" size="2">&quot; Accept gloabal as function parameter&quot;</font><font size="2">);
<p align="left"></p></font></font><font size="2">}</font></div>
<div>and call from the consequence of a rule : <font size="2">logMessage(customLogger);&nbsp; // I am passing the global to the function as an argument and then use it to log a message. </font></div>
<div><font size="2">This way is working. But not the first way of using the global in the function. </font></div>
<div><font size="2"></font>&nbsp;</div>
<div><font size="2">Any help??</font></div>
<p>Thanks<br>-- <br>Natraj Gudla </p>
<br>_______________________________________________<br>rules-users mailing list<br><a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br><a onclick="return top.js.OpenExtLink(window,event,this)" 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><br clear="all"><br>-- <br>&nbsp;&nbsp;Edson Tirelli<br>&nbsp;&nbsp;Software Engineer - JBoss Rules Core Developer<br>&nbsp;&nbsp;Office: +55 11 3529-6000<br>&nbsp;&nbsp;Mobile: +55 11 9287-5646
<br>&nbsp;&nbsp;JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a>