<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="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 11 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]-->
<style>
<!--
 /* Font Definitions */
 @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:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:blue;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:Arial;
        color:navy;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
        {page:Section1;}
-->
</style>

</head>

<body lang=EN-US link=blue vlink=blue>

<div class=Section1>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Great&#8230;..<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

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

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

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

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<div>

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

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

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

<p class=MsoNormal><b><font size=2 face=Tahoma><span style='font-size:10.0pt;
font-family:Tahoma;font-weight:bold'>From:</span></font></b><font size=2
face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'>
rules-users-bounces@lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] <b><span style='font-weight:bold'>On
Behalf Of </span></b>Wolfgang Laun<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</span></font><o:p></o:p></p>

</div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal style='margin-bottom:12.0pt'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>I'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<o:p></o:p></span></font></p>

<div>

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

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>Yeah..more fun with functions. &nbsp;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>
&nbsp; &nbsp; &nbsp; &nbsp;System.err.println(getMapRouterAddress());<br>
&nbsp; &nbsp; &nbsp; &nbsp;&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'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<o:p></o:p></span></font></p>

<div>

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

</div>

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

<div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>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">crichmond@referentia.com</a>&gt;<br>
Hmm&#8230;<br>
&nbsp;<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.&nbsp; Otherwise I have to implement another configuration settgin system<br>
then feed that to th setGlobal&#8230;<br>
&nbsp;<br>
Chris<br>
&nbsp;<br>
________________________________________<br>
From: <a href="mailto:rules-users-bounces@lists.jboss.org">rules-users-bounces@lists.jboss.org</a><br>
[mailto:<a href="mailto:rules-users-bounces@lists.jboss.org">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>
&nbsp;<br>
No, globals can only be set by calling the WorkingMemory method<br>
&nbsp;&nbsp; wm.setGlobal(String name, Object value)<br>
<br>
You could call this in a consequence (RHS), but it'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">crichmond@referentia.com</a>&gt;<br>
Shouldn&#8217;t it be possible to set a global variable value within the rule file<br>
itself at the top. &nbsp;Something like?<br>
&nbsp;<br>
&nbsp;<br>
global String deviceName = &#8220;myDevice&#8221;;<br>
&nbsp;<br>
&nbsp;<br>
&nbsp;<br>
I thought you could do that, but&nbsp; consistently get an error saying&nbsp;
illegal<br>
character &#8216;=&#8217; expected &#8220;(&#8220;<br>
&nbsp;<br>
Or something along those lines.<br>
&nbsp;<br>
This is possible and that syntax should work, shouldn&#8217;t it?<br>
&nbsp;<br>
Thanks,<br>
Chris<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>
&nbsp;<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>
<br>
<br>
<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><o:p></o:p></span></font></p>

</div>

</div>

</div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

</div>

</body>

</html>