[OpenSIPS-Users] concatenate an integer and a string

Liviu Chircu liviu at opensips.org
Mon Oct 18 09:38:01 EST 2021


On 18.10.2021 12:08, Alain Bieuzent wrote:
>
> When I try to concatenate with $var(result) = $avp(id_asterisk) + "|" 
> + $avp(codecs);) I got this error message :
>
> ERROR:core:eval_elem: invalid numeric operands
>
> WARNING:core:do_assign: no value in right expression at 
> /usr/local//etc/opensips/opensips.cfg:881
>
Hi,

The issue is that $avp(id_asterisk) contains an integer, so you cannot 
do "integer + string" concatenation in OpenSIPS.  However, what's 
interesting is that the OpenSIPS config language actually allows "string 
+ integer" concatenation!  So just fix it like this:

$var(result) = "" + $avp(id_asterisk) + "|" + $avp(codecs);

Best Regards,

-- 
Liviu Chircu
www.twitter.com/liviuchircu | www.opensips-solutions.com
OpenSIPS eBootcamp 2021: www.opensips.org/training

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20211018/9dd90787/attachment-0001.html>


More information about the Users mailing list