If you are using MVEL in rules, you must declare it, wherever it is used, in each rule.<br>-W<br><br><div class="gmail_quote">2009/10/14 Chris Richmond <span dir="ltr">&lt;<a href="mailto:crichmond@referentia.com">crichmond@referentia.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">









<div link="blue" vlink="blue" lang="EN-US">

<div>

<p class="MsoNormal"><font size="2" color="navy" face="Arial"><span style="font-size: 10pt; font-family: Arial; color: navy;">Great…..</span></font></p>

<p class="MsoNormal"><font size="2" color="navy" face="Arial"><span style="font-size: 10pt; font-family: Arial; color: navy;"> </span></font></p>

<p class="MsoNormal"><font size="2" color="navy" face="Arial"><span style="font-size: 10pt; font-family: Arial; color: navy;"> </span></font></p>

<p class="MsoNormal"><font size="2" color="navy" face="Arial"><span style="font-size: 10pt; font-family: Arial; color: navy;">So, can I simply switch the dialect to not
use MVEL?</span></font></p>

<p class="MsoNormal"><font size="2" color="navy" face="Arial"><span style="font-size: 10pt; font-family: Arial; color: navy;"> </span></font></p>

<p class="MsoNormal"><font size="2" color="navy" face="Arial"><span style="font-size: 10pt; font-family: Arial; color: navy;">Chris</span></font></p>

<p class="MsoNormal"><font size="2" color="navy" face="Arial"><span style="font-size: 10pt; font-family: Arial; color: navy;"> </span></font></p>

<p class="MsoNormal"><font size="2" color="navy" face="Arial"><span style="font-size: 10pt; font-family: Arial; color: navy;"> </span></font></p>

<p class="MsoNormal"><font size="2" color="navy" face="Arial"><span style="font-size: 10pt; font-family: Arial; color: navy;"> </span></font></p>

<div>

<div class="MsoNormal" style="text-align: center;" align="center"><font size="3" face="Times New Roman"><span style="font-size: 12pt;">

<hr size="3" width="100%" align="center">

</span></font></div>

<p class="MsoNormal"><b><font size="2" face="Tahoma"><span style="font-size: 10pt; font-family: Tahoma; font-weight: bold;">From:</span></font></b><font size="2" face="Tahoma"><span style="font-size: 10pt; font-family: Tahoma;">
<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><span style="font-weight: bold;">On
Behalf Of </span></b>Wolfgang Laun<div><div></div><div class="h5"><br>
<b><span style="font-weight: bold;">Sent:</span></b> Wednesday, October 14, 2009
8:50 AM<br>
<b><span style="font-weight: bold;">To:</span></b> Rules Users List<br>
<b><span style="font-weight: bold;">Subject:</span></b> Re: [rules-users] setting
globals in rule file</div></div></span></font></p>

</div><div><div></div><div class="h5">

<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="font-size: 12pt;"> </span></font></p>

<p class="MsoNormal" style="margin-bottom: 12pt;"><font size="3" face="Times New Roman"><span style="font-size: 12pt;">I&#39;ve used functions with
Drools 5, but not with MVEL. A recent thread seemed to indicate a problem with
MVEL for functions, though.<br>
<br>
What you show of your code appears to be OK.<br>
<br>
-W</span></font></p>

<div>

<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="font-size: 12pt;">On Wed, Oct 14, 2009 at 8:35 PM, Chris Richmond &lt;<a href="mailto:crichmond@referentia.com" target="_blank">crichmond@referentia.com</a>&gt; wrote:</span></font></p>


<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="font-size: 12pt;">Yeah..more fun with functions.  I have the following function<br>
<br>
function String getMyValue(){ return &quot;value 1&quot;; }<br>
<br>
I have declared it at the top of the rule file right after all imports and<br>
dialect statement but before any rules<br>
<br>
&lt;imports&gt;<br>
global Services services;<br>
global String currentProfilie;<br>
<br>
# setup dialect for the semantic code to be MVEL<br>
dialect &quot;mvel&quot;<br>
<br>
<br>
function String getMyValue(){ return &quot;value 1&quot;; }<br>
<br>
<br>
I then try to call the function from another rule consequence as a test:<br>
<br>
then<br>
       System.err.println(getMapRouterAddress());<br>
       &lt;other statements which work fine&gt;<br>
<br>
<br>
<br>
Now as soon as I start up and the rule file is loaded, I get a null pointer<br>
exception that isn&#39;t really helpful as it simpoly points to one of my own<br>
external objects that references the session that failed to load.<br>
<br>
I have tried using functions many times and never successfully done so.<br>
How/where do I place a simple function like this and call it?<br>
<br>
Thanks</span></font></p>

<div>

<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="font-size: 12pt;"><br>
Chris<br>
<br>
<br>
<br>
________________________________________<br>
From: <a href="mailto:rules-users-bounces@lists.jboss.org" target="_blank">rules-users-bounces@lists.jboss.org</a><br>
[mailto:<a href="mailto:rules-users-bounces@lists.jboss.org" target="_blank">rules-users-bounces@lists.jboss.org</a>]
On Behalf Of Wolfgang Laun</span></font></p>

</div>

<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="font-size: 12pt;">Sent: Wednesday, October 14, 2009 8:15 AM</span></font></p>

<div>

<div>

<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="font-size: 12pt;">To: Rules Users List<br>
Subject: Re: [rules-users] setting globals in rule file<br>
<br>
You could let the &quot;user&quot; write some functions such as<br>
<br>
function String parFoo(){ return &quot;foo42&quot;; }<br>
<br>
and evaluate them in a rule firing with high priority on eval(true).<br>
<br>
-W<br>
<br>
<br>
2009/10/14 Chris Richmond &lt;<a href="mailto:crichmond@referentia.com" target="_blank">crichmond@referentia.com</a>&gt;<br>
Hmm…<br>
 <br>
Well..I have this rule file and it seems like a darn convenient place to set<br>
some configuration settings so the user could change them in the plain text<br>
file.  Otherwise I have to implement another configuration settgin system<br>
then feed that to th setGlobal…<br>
 <br>
Chris<br>
 <br>
________________________________________<br>
From: <a href="mailto:rules-users-bounces@lists.jboss.org" target="_blank">rules-users-bounces@lists.jboss.org</a><br>
[mailto:<a href="mailto:rules-users-bounces@lists.jboss.org" target="_blank">rules-users-bounces@lists.jboss.org</a>]
On Behalf Of Wolfgang Laun<br>
Sent: Wednesday, October 14, 2009 7:50 AM<br>
To: Rules Users List<br>
Subject: Re: [rules-users] setting globals in rule file<br>
 <br>
No, globals can only be set by calling the WorkingMemory method<br>
   wm.setGlobal(String name, Object value)<br>
<br>
You could call this in a consequence (RHS), but it&#39;s usually not a good idea<br>
to do so.<br>
<br>
What do you want to achieve?<br>
<br>
-W<br>
2009/10/14 Chris Richmond &lt;<a href="mailto:crichmond@referentia.com" target="_blank">crichmond@referentia.com</a>&gt;<br>
Shouldn’t it be possible to set a global variable value within the rule file<br>
itself at the top.  Something like?<br>
 <br>
 <br>
global String deviceName = “myDevice”;<br>
 <br>
 <br>
 <br>
I thought you could do that, but  consistently get an error saying 
illegal<br>
character ‘=’ expected “(“<br>
 <br>
Or something along those lines.<br>
 <br>
This is possible and that syntax should work, shouldn’t it?<br>
 <br>
Thanks,<br>
Chris<br>
<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><br>
 <br>
<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><br>
<br>
<br>
<br>
<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></span></font></p>

</div>

</div>

</div>

<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="font-size: 12pt;"> </span></font></p>

</div></div></div>

</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>