<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>Hi Alex and guys,<div><br></div><div>Are there any further examples of XAVPs used in this manner?</div><div><br></div><div>So associate a number of variables by another variable?</div><div><br></div><div>I am trying with a number of scenarios but the penny is  yet to drop!</div><div><br></div><div>Sorry!</div><div><br></div><div>Jon</div><div><br></div><div><br></div><div> <div>From: hunterj91@hotmail.com<br>To: sr-users@lists.sip-router.org<br>Date: Fri, 23 Oct 2015 17:13:47 +0000<br>Subject: [SR-Users]  Multi-Array with AVPs<br><br>

<style><!--
.ExternalClass .ecxhmmessage P {
padding:0px;
}

.ExternalClass body.ecxhmmessage {
font-size:12pt;
font-family:Calibri;
}

--></style>
<div dir="ltr">Alex,<div><br></div><div>Thanks for the fast response!</div><div><br></div><div>I dont like hard mode, my lifes tough enough :)</div><div><br></div><div>Will try the XAVPs.</div><div><br></div><div>Thanks</div><div><br></div><div>Jon</div><div><br><div>> To: sr-users@lists.sip-router.org<br>> From: abalashov@evaristesys.com<br>> Date: Fri, 23 Oct 2015 13:07:27 -0400<br>> Subject: Re: [SR-Users] Multi-Array with AVPs<br>> <br>> Jon,<br>> <br>> For complex, nonscalar structures where members can be other AVP <br>> nonscalars, you might wish to consider XAVPs instead:<br>> <br>> http://www.kamailio.org/wiki/cookbooks/4.3.x/pseudovariables#xavp_id_-_xavps<br>> <br>> Otherwise, you're playing life on hard mode. ;-)<br>> <br>> -- Alex<br>> <br>> On 10/23/2015 01:00 PM, Jonathan Hunter wrote:<br>> <br>> > Hi Guys,<br>> ><br>> > Hope all are well?<br>> ><br>> > sorry to post but Im just trying to get something working where Im<br>> > trying to convert a php function script into the kamailio.cfg.<br>> ><br>> > Im getting there but wonder how I can group results of sets of avps with<br>> > another avp.<br>> ><br>> > Say I have these variables;<br>> ><br>> > $(avp(NTgrp)) =<br>> > 'SB100_000361@1.2.3.4|SB100_000213@1.2.3.5|SB100_000225@1.2.3.6|SB100_000361@1.2.3.7|SB100_000213@1.2.3.8';<br>> > $(avp(Prio)) = '1|1|1|2|2';<br>> > $(avp(Wgt)) = '10000|10000|80000|30000|70000';<br>> > $(avp(CInc)) = '0|0|1|0|1';<br>> > $(avp(WTot))= '100000|100000|100000|100000|100000';<br>> > I then run a while script to split up their variables via the delimiter<br>> > | in user;<br>> ><br>> > $var(j)=0;<br>> > while($var(j)<$var(count)) {<br>> > $(avp(NTgrpP))=$(avp(NTgrp){s.select,$var(j),|});<br>> > $(avp(PrioP))=$(avp(Prio){s.select,$var(j),|});<br>> > $(avp(WgtP))=$(avp(Wgt){s.select,$var(j),|});<br>> > $(avp(CIncP))=$(avp(CInc){s.select,$var(j),|});<br>> > $(avp(WTotP))=$(avp(WTot){s.select,$var(j),|});<br>> > xlog("L_INFO"," Now Each time we have $(avp(NTgrpP)) $(avp(PrioP))<br>> > $(avp(WgtP)) $(avp(CIncP)) $(avp(WTotP))\n");<br>> > $var(j)=$var(j)+1;<br>> > }<br>> ><br>> > This then results in;<br>> > INFO: <script>:  Now Each time we have SB100_000223@1.2.3.4 1 10000 0 100000<br>> > INFO: <script>:  Now Each time we have SB100_000225@1.2.3.5 1 10000 0 100000<br>> > INFO: <script>:  Now Each time we have SB100_000386@1.2.3.6 1 80000 0 100000<br>> > INFO: <script>:  Now Each time we have SB100_000213@1.2.3.7 2 30000 0 100000<br>> > INFO: <script>:  Now Each time we have SB100_000361@1.2.3.8 2 70000 0 100000<br>> ><br>> > Now what Id like to do is group them via priorities so I can do some<br>> > further functional checks on them when in same priority group, as you<br>> > can see there are 3 results at priority 1 and 2 at priority 2.<br>> ><br>> > Is there away I can create something of a multi-array using the AVP<br>> > $(avp(PrioP)) I just created so I can group by priority?<br>> ><br>> > As in php I would do something like;<br>> ><br>> > $multi_arr[$prio_arr[$p]][] = array(<br>> >        "ntgrp" => $ntgrp_arr[$p],<br>> >        "prio"  => $prio_arr[$p],<br>> >        "wght"  => $wght_arr[$p],<br>> >        "cinc"  => $cinc_arr[$p],<br>> >        "wtot"  => $wtot_arr[$p],<br>> >      );<br>> >    }<br>> ><br>> > Any help would be great.<br>> ><br>> > Many thanks<br>> ><br>> > Jon<br>> ><br>> ><br>> ><br>> > _______________________________________________<br>> > SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list<br>> > sr-users@lists.sip-router.org<br>> > http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users<br>> ><br>> <br>> <br>> -- <br>> Alex Balashov | Principal | Evariste Systems LLC<br>> 303 Perimeter Center North, Suite 300<br>> Atlanta, GA 30346<br>> United States<br>> <br>> Tel: +1-800-250-5920 (toll-free) / +1-678-954-0671 (direct)<br>> Web: http://www.evaristesys.com/, http://www.csrpswitch.com/<br>> <br>> _______________________________________________<br>> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list<br>> sr-users@lists.sip-router.org<br>> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users<br></div></div>                                          </div>
<br>_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</div></div>                                     </div></body>
</html>