Hi Jayesh, yes, you cannot initialized different vals for an AVP by using indexes...Why ? it is simple - the values are a continuous array, and by allowing init via indexes, you cannot guarantee this continuity (like setting val index 0 and setting val index 3....that is bogus).
Regards, Bogdan Jayesh Nambiar wrote: > Thank you Bogdan, actually this does a proper job. What I was doing > was slightly different which I realized later, I was trying to > initialize the AVP like this directly in my script: > $avp(i:999) = 0; > $(avp(variable)[$avp(i:999]) = $avp(value); > > This results an error in syslog saying: > ERROR:core:pv_set_avp: Failed to replace avp > ERROR:core:do_assign: setting PV failed > > I guess initializing an AVP is important with some value before > assigning a value to certain index, something like this: > $avp(variable) = $avp(default_value); > $avp(i:999) = 0; > $(avp(variable)[$avp(i:999]) = $avp(value); > > This works properly !!! So is it good to conclude that initializing an > AVP is important before trying to assign a value at any particular index. > > --- Jayesh > > > Hi Jayesh, > > Just tried the following script and it did the right job: > > <snap> > $avp(s:value1) = "abc"; > $avp(s:value2) = "ABC"; > > $avp(s:variable) = $avp(s:value1); > $avp(i:999) = 0; > $(avp(s:variable)[$avp(i:999)]) = $avp(s:value2); > > avp_print(); > </snap> > > and the result (from avp_print()) : > > Nov 4 11:32:49 [12046] INFO:avpops:ops_print_avp: p=0xb5ab5e48, > flags=0x0000 > Nov 4 11:32:49 [12046] INFO:avpops:ops_print_avp: > id=<999> > Nov 4 11:32:49 [12046] INFO:avpops:ops_print_avp: > val_int=<0> > Nov 4 11:32:49 [12046] INFO:avpops:ops_print_avp: p=0xb5ab5e70, > flags=0x0003 > Nov 4 11:32:49 [12046] INFO:avpops:ops_print_avp: > name=<variable> > Nov 4 11:32:49 [12046] INFO:avpops:ops_print_avp: > val_str=<ABC / 3> > Nov 4 11:32:49 [12046] INFO:avpops:ops_print_avp: p=0xb5ab5dc8, > flags=0x0003 > Nov 4 11:32:49 [12046] INFO:avpops:ops_print_avp: > name=<value2> > Nov 4 11:32:49 [12046] INFO:avpops:ops_print_avp: > val_str=<ABC / 3> > Nov 4 11:32:49 [12046] INFO:avpops:ops_print_avp: p=0xb5ab5d88, > flags=0x0003 > Nov 4 11:32:49 [12046] INFO:avpops:ops_print_avp: > name=<value1> > Nov 4 11:32:49 [12046] INFO:avpops:ops_print_avp: > val_str=<abc / 3> > > > Can you post the error/log you get? > > Regards, > Bogdan > > Jayesh Nambiar wrote: > > Hi All, > > I am trying to overwrite certain values at specific index of AVP and > > it doesn't work as expected. How I do it is: > > > > $avp(variable) = $avp(value1); > > $avp(i:999) = 0; > > $(avp(variable)[$avp(i:999)]) = $avp(value2); > > > > While executing this, opensips logs an error saying unable to > replace > > AVPs. Is the syntax wrong somewhere? I do this as I don't want > to add > > multiple values into single AVP and also I dont want to call > > avp_delete function before assigning a new value to the AVP. > Moreover > > the value at $avp(i:999) can change and thus it is assigned to > another > > AVP. > > > > Any help related to AVP overwriting function would be very helpful. > > > > --- Jayesh > > ------------------------------------------------------------------------ > > _______________________________________________ > Users mailing list > [email protected] > http://lists.opensips.org/cgi-bin/mailman/listinfo/users > -- Bogdan-Andrei Iancu OpenSIPS Bootcamp 15 - 19 November 2010, Edison, New Jersey, USA www.voice-system.ro _______________________________________________ Users mailing list [email protected] http://lists.opensips.org/cgi-bin/mailman/listinfo/users
