<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">Hello,<br>
<br>
It seems the OpenSIPS parser does not tolerate well constructs
like <br>
if ( ($var(t2) - $avp(diff) ) <= 0 )<br>
<br>
with expressions in the if conditions.<br>
<br>
While we fix this, a quick work-around would be to use an
auxiliary variable, like :<br>
$var(my_aux) = $var(t2) - $avp(diff);<br>
if ($var(my_aux) <= 0)<br>
....<br>
<br>
Also, I see that in your script you are using division operations.
I hope that you are aware that OpenSIPS has only integer support,
so you result vars will be truncated to int.<br>
If you want to use float operations, see <a
href="http://www.opensips.org/html/docs/modules/devel/mathops">http://www.opensips.org/html/docs/modules/devel/mathops</a>
, but please note that it is only available in the current
OpenSIPS trunk.<br>
<br>
Best Regards,<br>
Vlad<br>
<br>
Pe 4/28/2013 3:10 PM, Pinky harish chandran a scris:<br>
</div>
<blockquote
cite="mid:CAOOyDfdkZgH7Ow4uABkgVdUZAJouyhoVFJpU-BUsohrTcxiWGw@mail.gmail.com"
type="cite">
<div dir="ltr">
<p class=""><span style="font-family:'Courier New'">branch_route[2]
{<br>
xlog("new branch at
$ru\n");<br>
<br>
# values used for t1 and t2 and
the constants c1 and c2 and the threshold value <br>
<br>
$var(t1)=1;<br>
$var(t2)=60;<br>
$var(c1)=1;<br>
$var(c2)=3;<br>
$var(ts)=500;<br>
<br>
<br>
avp_db_query("select time
from acc where caller_id=$fu and max(time)","$avp(t)");<br>
<br>
avp_db_query("select ps,pl,pt,sh
from acc where caller_id=$fu" ,"$avp(val)");<br>
<br>
avp_db_query("delete
ps,pl,pt,sh from acc where caller_id=$fu");<br>
<br>
$avp(diff)=$avp(t)-$(avp(val)[2]);<br>
<br>
# calculation of long term gray
level <br>
<br>
if ( ($var(t2) - $avp(diff) )
> 0 )<br>
$avp(l)= $(avp(val)[1]) +
$var(c2)*($(avp(val)[0])+1)*($var(t2)-$avp(diff))/$var(t2);<br>
<br>
if ( ($var(t2) - $avp(diff) )
<= 0 )<br>
$avp(l)= $(avp(val)[1]) +
$var(c2)*(1-$(avp(val)[0]))/($(avp(val)[0])+1))*($var(t2)-$avp(diff))/$var(t2);<br>
<br>
if ( $avp(l) < 0 )<br>
$avp(l) = 0;<br>
<br>
# calculation of short term gray
level #<br>
<br>
<br>
if($avp(diff) > 1)<br>
{$avp(d)=$avp(diff);} <br>
else <br>
{$avp(d)=1;})<br>
<br>
if($avp(d)<$var(t1))<br>
{$avp(r)=$avp(d);}<br>
else<br>
{$avp(r)=$var(t1);}<br>
<br>
if ($avp(l) < $var(ts))<br>
$avp(s)=
$(avp(val)[3])+$var(c1)*($var(t1)-$avp(diff))/($avp(r));<br>
<br>
if ($avp(s) < 0)<br>
$avp(s) = 0;<br>
<br>
if ($avp(s) >= $var(ts))<br>
{<br>
$avp(l)= $avp(s);<br>
$avp(s)= 0 ;<br>
}<br>
<br>
# updating spam history<br>
<br>
if
((($(avp(val)[0])+$(avp(val)[1])) < $var(ts) )&&
(($avp(s)+$avp(l))
> $var(ts)))<br>
$(avp(val)[3])=
$(avp(val)[3])+1;<br>
<br>
# blocking the call<br>
<br>
$avp(sum) =$avp(l) +
$avp(s);<br>
if ($avp(sum) > $avp(ts)
)<br>
drop();<br>
<br>
#updating database<br>
<br>
avp_db_query(" insert
into acc (ps,pl,pt,sh) values
($avp(s),$avp(l),$avp(t),$(avp(val)[3]))");<br>
<br>
}<br>
</span></p>
<p class=""><span style="font-family:'Courier New'"><br>
</span></p>
<p class=""><span style="font-family:'Courier New'"><br>
</span></p>
<p class="" style=""><span style="font-family:'Courier New'">I
am getting syntax error in this code...can anyone help me
out here ??please...</span></p>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a>
<a class="moz-txt-link-freetext" href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a>
</pre>
</blockquote>
<br>
</body>
</html>