[OpenSER-Users] get Count of items in lists

Henning Westerholt henning.westerholt at 1und1.de
Thu Dec 13 10:33:13 CET 2007


On Wednesday 12 December 2007, Dave Singer wrote:
> using openser 1.3, is there a way to get a count of how many items there
> are in an avp variable other than:
> while ( is_avp_set("$avp(s:fork_uri)") )
>     {
>         $var(fork_uri_count) = $var(fork_uri_count) + 1 ;
>         avp_copy("$avp(s:fork_uri)", "$avp(s:fork_uri_rev_order)/d") ;
>     }
> then if you wanted things in the same order as they were originally you
> would also have to:
> while ( is_avp_set("$avp(s:fork_uri_rev_order)") )
>     {
>         avp_copy("$avp(s:fork_uri_rev_order)", "$avp(s:fork_uri)/d") ;
>     }
>
> talk about an expensive counting

Hello Dave,

i think the best way to implement this would be as a transformation, see 
http://www.openser.org/dokuwiki/doku.php/transformations:devel

You could implement a operation like $avp(..){s.count} that return the wanted 
number.

Cheers,

Henning




More information about the Users mailing list