<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>Hello,</p>
<p>things are different that one may expect from evaluation of an
expression compared with other established scripting/programming
languages. One thing to be sure you are aware of are the return
code evaluation:</p>
<p> -
<a class="moz-txt-link-freetext" href="https://www.kamailio.org/wiki/tutorials/faq/main#how_is_the_function_return_cod">https://www.kamailio.org/wiki/tutorials/faq/main#how_is_the_function_return_cod</a></p>
<p>To be sure of proper behaviour, you should do:</p>
<p>if(uri =~ "<regex string to match>" || uri == myself) {</p>
<p>$var(myself) =1;</p>
<p>} else {</p>
<p>$var(myself) = 0;</p>
<p>}</p>
<p>Same with is_myself("$ru") instead of uri == myself.</p>
<p>Try and see if you get different values for $var(myself).<br>
</p>
Cheers,<br>
Daniel<br>
<br>
<div class="moz-cite-prefix">On 19.07.18 19:09, Karthik Srinivasan
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAHUhqa-_RydeaOJt5DQvikFNAceJATmq8rf_GfUqt9YT7EH5Pw@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<div dir="ltr">Yes, they are used at the very same place. here is
a code snippet of where i added it for testing purposes:
<div><br>
</div>
<div><br>
</div>
<div>
<div>
<div>route[INIT_VARS] {</div>
</div>
<div><br>
</div>
<div>$var(myself) = uri =~ "<regex string to match>" ||
uri == myself;<br>
</div>
<div>//if i print $var(myself) it prints 0 </div>
<div>$var(myself) = uri =~ "<regex string to match>" ||
is_myself("$ru");<br>
</div>
<div>//if i print $var(myself) it prints 1 </div>
<div><br>
</div>
<div>// in both cases above the regex part isn't supposed to
match and hence correctly returns false.</div>
<div>...</div>
<div><br>
</div>
<div>}</div>
<div><br>
</div>
<div>route{</div>
<div><br>
</div>
<div> route(INIT_VARS);</div>
<div><br>
</div>
</div>
<div>...</div>
<div>}</div>
<div><br>
</div>
<div>Thanks,</div>
<div><br>
</div>
<div>Karthik</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Thu, Jul 19, 2018 at 11:46 AM,
Daniel-Constantin Mierla <span dir="ltr"><<a
href="mailto:miconda@gmail.com" target="_blank"
moz-do-not-send="true">miconda@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
<br>
On 19.07.18 18:32, Karthik Srinivasan wrote:<br>
> Hello,<br>
><br>
> Can someone explain to me why statement A returns True
and statement B<br>
> returns False.<br>
><br>
> Statement A:<br>
> is_myself("$ru")<br>
><br>
> Statement B:<br>
> uri == myself<br>
><br>
><br>
> Isn't uri and $ru referencing the same data? <br>
><br>
> With my current config i am expecting the is_myself to
return True; i<br>
> was expecting the same for Statement B but
unfortunately it is<br>
> returning False.<br>
><br>
they are supposed to be the same in this case.<br>
<br>
Are they used at the same place in config? Note that $ru can
be changed<br>
by different functions such as those from registrar,
dispatcher, lcr, ...<br>
<br>
Cheers,<br>
Daniel<br>
<span class="HOEnZb"><font color="#888888"><br>
-- <br>
Daniel-Constantin Mierla -- <a
href="http://www.asipto.com" rel="noreferrer"
target="_blank" moz-do-not-send="true">www.asipto.com</a><br>
<a href="http://www.twitter.com/miconda"
rel="noreferrer" target="_blank"
moz-do-not-send="true">www.twitter.com/miconda</a> --
<a href="http://www.linkedin.com/in/miconda"
rel="noreferrer" target="_blank"
moz-do-not-send="true">www.linkedin.com/in/miconda</a><br>
Kamailio World Conference -- <a
href="http://www.kamailioworld.com" rel="noreferrer"
target="_blank" moz-do-not-send="true">www.kamailioworld.com</a><br>
<br>
</font></span></blockquote>
</div>
<br>
</div>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
Daniel-Constantin Mierla -- <a class="moz-txt-link-abbreviated" href="http://www.asipto.com">www.asipto.com</a>
<a class="moz-txt-link-abbreviated" href="http://www.twitter.com/miconda">www.twitter.com/miconda</a> -- <a class="moz-txt-link-abbreviated" href="http://www.linkedin.com/in/miconda">www.linkedin.com/in/miconda</a>
Kamailio World Conference -- <a class="moz-txt-link-abbreviated" href="http://www.kamailioworld.com">www.kamailioworld.com</a></pre>
</body>
</html>