Hello,
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:
- https://www.kamailio.org/wiki/tutorials/faq/main#how_is_the_function_return_cod
To be sure of proper behaviour, you should do:
if(uri =~ "<regex string to match>" || uri == myself) {
$var(myself) =1;
} else {
$var(myself) = 0;
}
Same with is_myself("$ru") instead of uri == myself.
Try and see if you get different values for $var(myself).
Yes, they are used at the very same place. here is a code snippet of where i added it for testing purposes:
route[INIT_VARS] {
$var(myself) = uri =~ "<regex string to match>" || uri == myself;
//if i print $var(myself) it prints 0$var(myself) = uri =~ "<regex string to match>" || is_myself("$ru");
//if i print $var(myself) it prints 1
// in both cases above the regex part isn't supposed to match and hence correctly returns false....
}
route{
route(INIT_VARS);
...}
Thanks,
Karthik
On Thu, Jul 19, 2018 at 11:46 AM, Daniel-Constantin Mierla <miconda@gmail.com> wrote:
Hello,
On 19.07.18 18:32, Karthik Srinivasan wrote:
> Hello,
>
> Can someone explain to me why statement A returns True and statement B
> returns False.
>
> Statement A:
> is_myself("$ru")
>
> Statement B:
> uri == myself
>
>
> Isn't uri and $ru referencing the same data?
>
> With my current config i am expecting the is_myself to return True; i
> was expecting the same for Statement B but unfortunately it is
> returning False.
>
they are supposed to be the same in this case.
Are they used at the same place in config? Note that $ru can be changed
by different functions such as those from registrar, dispatcher, lcr, ...
Cheers,
Daniel
--
Daniel-Constantin Mierla -- www.asipto.com
www.twitter.com/miconda -- www.linkedin.com/in/miconda
Kamailio World Conference -- www.kamailioworld.com
-- Daniel-Constantin Mierla -- www.asipto.com www.twitter.com/miconda -- www.linkedin.com/in/miconda Kamailio World Conference -- www.kamailioworld.com