<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body 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 class="moz-signature" cols="72">Bogdan-Andrei Iancu
OpenSIPS Founder and Developer
<a class="moz-txt-link-freetext" href="http://www.opensips-solutions.com">http://www.opensips-solutions.com</a></pre>
    <div class="moz-cite-prefix">On 14.09.2016 16:59, Benjamin Cropley
      wrote:<br>
    </div>
    <blockquote
cite="mid:CAF7jiz+USqTe2bfDdnxWh+4EtY7qXyCVOet_boULvpaxHKkK7w@mail.gmail.com"
      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=="INVITE")
            {</font></div>
        <div><font face="monospace, monospace">       
            if(is_present_hf("X-Info")){</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,;});</font></div>
        <div><font face="monospace, monospace">           
            $var(e)=$(var(c){s.select,3,;});</font></div>
        <div><font face="monospace, monospace">           
            $var(f)=$(var(c){s.select,4,;});</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( "L_NOTICE",
            "CallCenter_Info &amp; $ci,$var(c) \n" );</font></div>
        <div><font face="monospace, monospace">        xlog( "L_NOTICE",
            "3CLogicCDR &amp; $ci,$fU,$oU,$rd \n" );</font></div>
        <div><font face="monospace, monospace">        xlog("L_NOTICE",
            " Source IP ($si) :  method ($rm) r-uri ($ru) : callID $ci
            \n");</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)="";</font></div>
        <div><font face="monospace, monospace">        $var(d)="";</font></div>
        <div><font face="monospace, monospace">        $var(e)="";</font></div>
        <div><font face="monospace, monospace">        $var(f)="";</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 moz-do-not-send="true"
            href="https://www.opensips.org/Documentation/Script-CoreVar-1-6#toc1">https://www.opensips.org/Documentation/Script-CoreVar-1-6#toc1</a>
          and <a moz-do-not-send="true"
            href="https://www.opensips.org/Documentation/Script-CoreVar-1-11#toc1">https://www.opensips.org/Documentation/Script-CoreVar-1-11#toc1</a>).
          Maybe something else is going on to make it 'work' 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 moz-do-not-send="true"
              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=="INVITE") {</font></b>
                <div><b><font color="#20124d"><br>
                    </font></b></div>
                <div><b><font color="#20124d">                   
                      if(is_present_hf("X-Info"))<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(
                      "L_NOTICE", "CallCenter_Info &amp; $ci,$var(c) \n"
                      );</font></b></div>
                <div><b><font color="#20124d">                    xlog(
                      "L_NOTICE", "3CLogicCDR &amp; $ci,$fU,$oU,$rd \n"
                      );</font></b></div>
                <div><b><font color="#20124d">                   
                      xlog("L_NOTICE", " Source IP ($si) :  method ($rm)
                      r-uri ($ru) : callID $ci \n");</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 "X-Info" from INVITE message and printing
                  it in logs in place of "$var(c)" . When an INVITE
                  message doesn't have "X-Info" header it prints
                  "&lt;null&gt;" in place of "$var(c)" 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 "X-Info"  it prints the value
                    corresponding to that . In the next call , lets the
                    INVITE message don't have "X-Info" , for this rather
                    than printing "&lt;null&gt;" in place of "$var(c)"  </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
                        class="HOEnZb"><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 moz-do-not-send="true"
              href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a><br>
            <a moz-do-not-send="true"
              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 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>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
Users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a>
<a class="moz-txt-link-freetext" href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>