<div dir="ltr">OK so:<div><br></div><div>1- <a class="gmail_plusreply" id="plusReplyChip-0" href="mailto:hw@kamailio.org" tabindex="-1">@Henning Westerholt</a>: I wasn't aware of $_s(format), very useful, thanks for the pointer! (I tested it :P, and although it doesn't work for <u>this</u> case, it's one of those good-to-know things)<br><div>2- <a class="gmail_plusreply" id="plusReplyChip-1" href="mailto:miconda@gmail.com" tabindex="-1">@Daniel-Constantin Mierla</a>: you are correct, it only works with constants, I tried all combinations (even AVP inside REGEX, etc), and they all give an error (matching what you said).</div></div><div><br></div><div>In this case I need to use AVPs not constants, so I've switched from "switch/case" to "if/elseif/else", but I've learned something new :-)</div><div><br></div><div>Thank you both for your help!</div><div>Joel.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jun 22, 2021 at 2:24 AM Daniel-Constantin Mierla <<a href="mailto:miconda@gmail.com">miconda@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
  
    
  
  <div>
    <p>Hello,</p>
    <p>case values have to be constants, not variables, based on a quick
      look at the code, as I haven't implemented it. But this is anyhow
      the common for switch/case statements. The core cookbook also has
      the example only with constants.</p>
    <p>Cheers,<br>
      Daniel<br>
    </p>
    <div>On 22.06.21 10:29, Joel Serrano wrote:<br>
    </div>
    <blockquote type="cite">
      
      <div dir="ltr">Hi guys, 
        <div><br>
        </div>
        <div>Quick question, are AVPs valid in "switch" as "case"'s?</div>
        <div><br>
        </div>
        <div>Example:</div>
        <div><br>
        </div>
        <div>
          <div style="color:rgb(171,178,191);background-color:rgb(40,44,52);font-family:Menlo,Monaco,"Courier New",monospace;font-size:12px;line-height:18px;white-space:pre-wrap"><div>            $avp(var1) = <span style="color:rgb(152,195,121)">"101"</span>;</div><div>            $avp(var2) = <span style="color:rgb(152,195,121)">"201"</span>;</div><div>            <span style="color:rgb(198,120,221)">switch</span>($rU) {</div><div>                <span style="color:rgb(198,120,221)">case</span> <span style="color:rgb(152,195,121)">"$avp(var1)"</span>:</div><div>                    ...</div><div>                <span style="color:rgb(198,120,221)">break</span>;</div><div>                <span style="color:rgb(198,120,221)">case</span> <span style="color:rgb(152,195,121)">"$avp(var2)"</span>:</div><div>                    ...</div><div>                <span style="color:rgb(198,120,221)">break</span>;</div><div>                <span style="color:rgb(198,120,221)">default</span>:</div><div>                    send_reply(<span style="color:rgb(152,195,121)">"403"</span>, <span style="color:rgb(152,195,121)">"Forbidden"</span>);</div><div>                    <span style="color:rgb(97,175,239)">exit</span>;</div><div>            }</div></div>
        </div>
        <div><br>
        </div>
        <div>For some reason I can't get the case to match, and I'm
          thinking it's not using the actual value of $avp(var1) and
          instead it's using literally "$avp(var1)" as a string.<br>
        </div>
        <div><br>
        </div>
        <div>NOTE: I also tried without putting the AVPs in quotes, but
          Kamailio complains and doesn't start.</div>
        <div><br>
        </div>
        <div>Is this doable or do I need to use if..else if..else
          if..else for this?</div>
        <div><br>
        </div>
        <div>Thanks, </div>
        <div>Joel.</div>
      </div>
      <br>
      <fieldset></fieldset>
      <pre>__________________________________________________________
Kamailio - Users Mailing List - Non Commercial Discussions
  * <a href="mailto:sr-users@lists.kamailio.org" target="_blank">sr-users@lists.kamailio.org</a>
Important: keep the mailing list in the recipients, do not reply only to the sender!
Edit mailing list options or unsubscribe:
  * <a href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users" target="_blank">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a>
</pre>
    </blockquote>
    <pre cols="72">-- 
Daniel-Constantin Mierla -- <a href="http://www.asipto.com" target="_blank">www.asipto.com</a>
<a href="http://www.twitter.com/miconda" target="_blank">www.twitter.com/miconda</a> -- <a href="http://www.linkedin.com/in/miconda" target="_blank">www.linkedin.com/in/miconda</a></pre>
  </div>

</blockquote></div>