<div dir="ltr">I was just following the doc :)<div><br></div>&quot;if you want to start using a script variable in a route, better initialize it with same value <b>(or reset it)</b>, otherwise you may inherit a value from a previous route that was executed by the same process.&quot;</div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Sep 14, 2016 at 3:23 PM, Bogdan-Andrei Iancu <span dir="ltr">&lt;<a href="mailto:bogdan@opensips.org" target="_blank">bogdan@opensips.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div bgcolor="#FFFFFF" text="#000000">
    <tt>Hi,<br>
      <br>
      Ideally you should init the vars before their usage, rather than
      trying to reset afterwards. It is much safer.<br>
      <br>
      Regards,<br>
    </tt>
    <pre cols="72">Bogdan-Andrei Iancu
OpenSIPS Founder and Developer
<a href="http://www.opensips-solutions.com" target="_blank">http://www.opensips-solutions.<wbr>com</a></pre><div><div class="h5">
    <div>On 14.09.2016 16:59, Benjamin Cropley
      wrote:<br>
    </div>
    <blockquote type="cite">
      <div dir="ltr">
        <div>the value of script variables persists over any given
          OpenSIPS process. Therefore, to ensure the value is null on
          every entry to the route (if a subsequent packet is recieved
          on the same process) you must set the value back to Null
          before the route is exited.</div>
        <div><br>
        </div>
        <div>eg..</div>
        <div><font face="monospace, monospace">route{</font></div>
        <div><font face="monospace, monospace">    if (method==&quot;INVITE&quot;)
            {</font></div>
        <div><font face="monospace, monospace">       
            if(is_present_hf(&quot;X-Info&quot;)){</font></div>
        <div><font face="monospace, monospace">            # assign
            values to vars...</font></div>
        <div><font face="monospace, monospace">           
            $var(c)=$hdr(X-Info);</font></div>
        <div><font face="monospace, monospace">           
            $var(d)=$(var(c){s.select,2,;}<wbr>);</font></div>
        <div><font face="monospace, monospace">           
            $var(e)=$(var(c){s.select,3,;}<wbr>);</font></div>
        <div><font face="monospace, monospace">           
            $var(f)=$(var(c){s.select,4,;}<wbr>);</font></div>
        <div><font face="monospace, monospace">        }</font></div>
        <div><font face="monospace, monospace"><br>
          </font></div>
        <div><font face="monospace, monospace">        #Set the flag for
            counting the dialogs. We user flag=4 for counting dialogs</font></div>
        <div><font face="monospace, monospace">        setflag(2);</font></div>
        <div><font face="monospace, monospace">        setflag(4);</font></div>
        <div><font face="monospace, monospace">        xlog( &quot;L_NOTICE&quot;,
            &quot;CallCenter_Info &amp; $ci,$var(c) \n&quot; );</font></div>
        <div><font face="monospace, monospace">        xlog( &quot;L_NOTICE&quot;,
            &quot;3CLogicCDR &amp; $ci,$fU,$oU,$rd \n&quot; );</font></div>
        <div><font face="monospace, monospace">        xlog(&quot;L_NOTICE&quot;,
            &quot; Source IP ($si) :  method ($rm) r-uri ($ru) : callID $ci
            \n&quot;);</font></div>
        <div><font face="monospace, monospace">        </font></div>
        <div><font face="monospace, monospace">        # set vars back
            to null..</font></div>
        <div><font face="monospace, monospace">        $var(c)=&quot;&quot;;</font></div>
        <div><font face="monospace, monospace">        $var(d)=&quot;&quot;;</font></div>
        <div><font face="monospace, monospace">        $var(e)=&quot;&quot;;</font></div>
        <div><font face="monospace, monospace">        $var(f)=&quot;&quot;;</font></div>
        <div><font face="monospace, monospace">        exit;</font></div>
        <div><font face="monospace, monospace">    }</font></div>
        <div><font face="monospace, monospace">}</font></div>
        <div><br>
        </div>
        <div>I think this feature will have existed in both 1.6 and 1.11
          (see <a href="https://www.opensips.org/Documentation/Script-CoreVar-1-6#toc1" target="_blank">https://www.opensips.org/<wbr>Documentation/Script-CoreVar-<wbr>1-6#toc1</a>
          and <a href="https://www.opensips.org/Documentation/Script-CoreVar-1-11#toc1" target="_blank">https://www.opensips.org/<wbr>Documentation/Script-CoreVar-<wbr>1-11#toc1</a>).
          Maybe something else is going on to make it &#39;work&#39; in 1.6?</div>
      </div>
      <div class="gmail_extra"><br>
        <div class="gmail_quote">On Wed, Sep 14, 2016 at 2:34 PM,
          Sasmita Panda <span dir="ltr">&lt;<a href="mailto:spanda@3clogic.com" target="_blank">spanda@3clogic.com</a>&gt;</span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div dir="ltr">Hi All ,
              <div><br>
              </div>
              <div> I am using opensips-1.11 . </div>
              <div><br>
              </div>
              <div>My config file looks like bellow .</div>
              <div><br>
              </div>
              <div><b> <font color="#20124d">   if (method==&quot;INVITE&quot;) {</font></b>
                <div><b><font color="#20124d"><br>
                    </font></b></div>
                <div><b><font color="#20124d">                   
                      if(is_present_hf(&quot;X-Info&quot;))<br>
                    </font></b></div>
                <div><b><font color="#20124d">                       {</font></b></div>
                <div><b><font color="#20124d">                       
                      $var(c)=$hdr(X-Info);</font></b></div>
                <div><b><font color="#20124d">                       
                      $var(d)=$(var(c){s.select,2,;}<wbr>);</font></b></div>
                <div><b><font color="#20124d">                       
                      $var(e)=$(var(c){s.select,3,;}<wbr>);</font></b></div>
                <div><b><font color="#20124d">                       
                      $var(f)=$(var(c){s.select,4,;}<wbr>);</font></b></div>
                <div><b><font color="#20124d">                       }</font></b></div>
                <div><b><font color="#20124d"><br>
                    </font></b></div>
                <div><b><font color="#20124d"><br>
                    </font></b></div>
                <div><b><font color="#20124d"><span style="white-space:pre-wrap">        </span>
                             #Set the flag for counting the dialogs. We
                      user flag=4 for counting dialogs</font></b></div>
                <div><b><font color="#20124d"><span style="white-space:pre-wrap">                </span>
                         setflag(2);</font></b></div>
                <div><b><font color="#20124d"><span style="white-space:pre-wrap">                </span>
                         setflag(4);</font></b></div>
                <div><b><font color="#20124d">                    xlog(
                      &quot;L_NOTICE&quot;, &quot;CallCenter_Info &amp; $ci,$var(c) \n&quot;
                      );</font></b></div>
                <div><b><font color="#20124d">                    xlog(
                      &quot;L_NOTICE&quot;, &quot;3CLogicCDR &amp; $ci,$fU,$oU,$rd \n&quot;
                      );</font></b></div>
                <div><b><font color="#20124d">                   
                      xlog(&quot;L_NOTICE&quot;, &quot; Source IP ($si) :  method ($rm)
                      r-uri ($ru) : callID $ci \n&quot;);</font></b></div>
                <div><b><font color="#20124d"><span style="white-space:pre-wrap">                                        </span>}</font></b></div>
                <div><br>
                </div>
                <div><br>
                </div>
                <div>           What I am trying to do is , I am
                  extracting &quot;X-Info&quot; from INVITE message and printing
                  it in logs in place of &quot;$var(c)&quot; . When an INVITE
                  message doesn&#39;t have &quot;X-Info&quot; header it prints
                  &quot;&lt;null&gt;&quot; in place of &quot;$var(c)&quot; in logs .</div>
                <div><br>
                </div>
                <div><br>
                </div>
                <div>         <b> This is working fine in opensips-1.6 .
                    For each and every call the $var(c) is getting
                    updated . </b></div>
                <div><br>
                </div>
                <div>          <b>I am facing some problem in
                    opensips-1.11 . For example : When I am doing a call
                    which has &quot;X-Info&quot;  it prints the value
                    corresponding to that . In the next call , lets the
                    INVITE message don&#39;t have &quot;X-Info&quot; , for this rather
                    than printing &quot;&lt;null&gt;&quot; in place of &quot;$var(c)&quot;  </b><b>its
                    printing the previous value .</b></div>
                <div><b><br>
                  </b></div>
                <div><b><br>
                  </b></div>
                <div><b>      I am not getting why this is happening .
                    Please help me . I think the variable is getting
                    saved somewhere and getting printed again and again
                    .  </b></div>
                <div><br>
                </div>
                <div>      How can I solve this problem . Its very
                  critical for me . It will affect my CDR . Please help
                  me .</div>
                <div><br>
                </div>
                <div>
                  <div>
                    <div dir="ltr"><b><i>Thanks &amp; Regards</i></b><span><font color="#888888">
                          <div><i>Sasmita Panda</i></div>
                          <div><i>Network Testing and Software Engineer</i></div>
                          <div><i>3CLogic , ph:07827611765</i></div>
                        </font></span></div>
                  </div>
                </div>
              </div>
            </div>
            <br>
            ______________________________<wbr>_________________<br>
            Users mailing list<br>
            <a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a><br>
            <a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.opensips.org/cgi-<wbr>bin/mailman/listinfo/users</a><br>
            <br>
          </blockquote>
        </div>
        <br>
        <br clear="all">
        <div><br>
        </div>
        -- <br>
        <div data-smartmail="gmail_signature">
          <div dir="ltr">All the best,
            <div>Ben Cropley</div>
            <div>07539 366 905</div>
          </div>
        </div>
      </div>
      <br>
      <fieldset></fieldset>
      <br>
      <pre>______________________________<wbr>_________________
Users mailing list
<a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-<wbr>bin/mailman/listinfo/users</a>
</pre>
    </blockquote>
    <br>
  </div></div></div>

</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">All the best,<div>Ben Cropley</div><div>07539 366 905</div></div></div>
</div>