Hi Herman,<br><br>These are common questions when dealing with the dialplan. I highly recommend that you acquire the FreeSWITCH &quot;bridge book&quot; (see link near top of <a href="http://wiki.freeswitch.org">wiki.freeswitch.org</a>) and read chapters 5 and 8. (Full disclosure: I wrote chapter 5 and Darren Schreiber wrote chapter 8.) Both of these chapters cover the break attribute in detail. I think you might be confusing the purpose of the break attribute. <br>
<br>Consider this dp fragment:<br><font style="font-family:courier new,monospace" size="1">&lt;extension name=&quot;test&quot;&gt;<br>  &lt;condition field=&quot;foo&quot; expression=&quot;bar&quot;/&gt;<br>  &lt;condition field=&quot;foo2&quot; expression=&quot;bar2&quot;&gt;<br>
    &lt;!-- actions here get added to task list only if both conditions are true --&gt;<br></font><font style="font-family:courier new,monospace" size="1">    &lt;!-- anti-actions here get added to task list only if foo is true and foo2 is false --&gt;</font><br>
<font style="font-family:courier new,monospace" size="1">  &lt;/condition&gt;<br>&lt;/extension&gt;<br></font><br>When the dialplan parser gets to this extension, the first thing it does is test the &quot;foo&quot; field. If the test fails then the parser <i>does not even look at the rest of this extension</i>. Why not? Because all conditions have an implied break=&quot;on-false&quot;. The following two conditions are identical in function:<br>
<font style="font-family:courier new,monospace" size="1">  &lt;condition field=&quot;foo&quot; expression=&quot;bar&quot;/&gt;<br></font><font style="font-family:courier new,monospace" size="1">  &lt;condition field=&quot;foo&quot; expression=&quot;bar&quot; break=&quot;on-false/&gt;<br>

</font><font style="font-family:courier new,monospace" size="1">
</font><br>So, if you want a set of actions to be included only if more than one condition is met then &quot;stacking&quot; will work, however you cannot do break=&quot;never&quot;. Why not? Because break=&quot;never&quot; tells the dialplan parser, &quot;Hey, even if this condition fails, go ahead and evaluate the next condition in this extension.&quot; If you have break=&quot;on-false&quot; (or no &#39;break&#39; attribute at all) then that tells the dialplan parser, &quot;Hey, if this condition fails then &#39;break out&#39; of this extension and continue parsing the dialplan.&quot; <br>
<br>Using what we&#39;ve just discussed, let&#39;s look at the example you cited in your second post.<br>Dialplan extension &quot;emergency_set_variables&quot;:<br><br><font size="1"><span style="font-family:courier new,monospace;color:rgb(153,51,153)">&lt;condition field=&quot;${caller_id_name}&quot; expression=&quot;^Emerg_&quot; break=&quot;never&quot;&gt;</span><br style="font-family:courier new,monospace;color:rgb(153,51,153)">
<span style="font-family:courier new,monospace;color:rgb(153,51,153)">
    &lt;action application=&quot;set&quot; data=&quot;emergency_call=true&quot; inline=&quot;true&quot;/&gt;</span><br style="font-family:courier new,monospace;color:rgb(153,51,153)"><span style="font-family:courier new,monospace;color:rgb(153,51,153)">
 &lt;/condition&gt;</span><br style="font-family:courier new,monospace;color:rgb(153,51,153)"><span style="font-family:courier new,monospace;color:rgb(153,51,153)">
</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">
<span style="color:rgb(255,102,0)"> &lt;condition wday=&quot;2-6&quot; time-of-day=&quot;22:00-23:59&quot; break=&quot;never&quot;&gt;</span></span><br style="font-family:courier new,monospace;color:rgb(255,102,0)"><span style="font-family:courier new,monospace;color:rgb(255,102,0)">
     &lt;action application=&quot;set&quot; data=&quot;open=true&quot; inline=&quot;true&quot;/&gt;</span><br style="font-family:courier new,monospace;color:rgb(255,102,0)"><span style="font-family:courier new,monospace;color:rgb(255,102,0)">
 &lt;/condition&gt;</span><br style="font-family:courier new,monospace;color:rgb(255,102,0)"><span style="font-family:courier new,monospace;color:rgb(255,102,0)">
</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">
<span style="color:rgb(0,153,0)"> &lt;condition wday=&quot;1,7&quot; time-of-day=&quot;05:00-23:59&quot; break=&quot;never&quot;&gt;</span></span><br style="font-family:courier new,monospace;color:rgb(0,153,0)"><span style="font-family:courier new,monospace;color:rgb(0,153,0)">
     &lt;action application=&quot;set&quot; data=&quot;open=true&quot; inline=&quot;true&quot;/&gt;</span><br style="font-family:courier new,monospace;color:rgb(0,153,0)"><span style="font-family:courier new,monospace;color:rgb(0,153,0)">
 &lt;/condition&gt;</span><br style="font-family:courier new,monospace;color:rgb(0,153,0)"></font><br>The dialplan parser logged this:<br><font size="1"><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace;background-color:rgb(255,255,255);color:rgb(153,51,153)">Dialplan: sofia/external/</span><a style="font-family:courier new,monospace;background-color:rgb(255,255,255);color:rgb(153,51,153)" href="mailto:Unknown@72.37.252.18">Unknown@72.37.252.18</a><span style="font-family:courier new,monospace;background-color:rgb(255,255,255);color:rgb(153,51,153)"> Regex (FAIL)</span><br style="font-family:courier new,monospace;background-color:rgb(255,255,255);color:rgb(153,51,153)">
<span style="font-family:courier new,monospace;background-color:rgb(255,255,255);color:rgb(153,51,153)">
[emergency_set_variables] ${caller_id_name}(Unknown) =~ /^Emerg_/</span><br style="font-family:courier new,monospace;background-color:rgb(255,255,255);color:rgb(153,51,153)"><span style="font-family:courier new,monospace;background-color:rgb(255,255,255);color:rgb(153,51,153)">
break=never</span><br style="font-family:courier new,monospace;background-color:rgb(153,51,153)"><span style="font-family:courier new,monospace"><span style="background-color:rgb(153,51,153)">
</span><span style="color:rgb(255,102,0)">Dialplan: sofia/external/</span></span><a style="font-family:courier new,monospace;color:rgb(255,102,0)" href="mailto:Unknown@72.37.252.18">Unknown@72.37.252.18</a><span style="font-family:courier new,monospace;color:rgb(255,102,0)"> Date/TimeMatch (FAIL)</span><br style="font-family:courier new,monospace;color:rgb(255,102,0)">
<span style="font-family:courier new,monospace;color:rgb(255,102,0)">
[emergency_set_variables] break=never</span><br style="font-family:courier new,monospace;color:rgb(255,102,0)"><span style="font-family:courier new,monospace"><span style="color:rgb(255,102,0)">
</span><span style="color:rgb(0,153,0)">Dialplan: sofia/external/</span></span><a style="font-family:courier new,monospace;color:rgb(0,153,0)" href="mailto:Unknown@72.37.252.18">Unknown@72.37.252.18</a><span style="font-family:courier new,monospace;color:rgb(0,153,0)"> Date/Time Match (PASS)</span><br style="font-family:courier new,monospace;color:rgb(0,153,0)">
<span style="font-family:courier new,monospace;color:rgb(0,153,0)">
[emergency_set_variables] break=never</span><br style="font-family:courier new,monospace;color:rgb(0,153,0)"><span style="font-family:courier new,monospace;color:rgb(0,153,0)">
Dialplan: sofia/external/</span><a style="font-family:courier new,monospace;color:rgb(0,153,0)" href="mailto:Unknown@72.37.252.18">Unknown@72.37.252.18</a><span style="font-family:courier new,monospace;color:rgb(0,153,0)"> Action set(open=true) INLINE</span><br style="font-family:courier new,monospace;color:rgb(0,153,0)">
<span style="font-family:courier new,monospace;color:rgb(0,153,0)">
EXECUTE sofia/external/</span><a style="font-family:courier new,monospace;color:rgb(0,153,0)" href="mailto:Unknown@72.37.252.18">Unknown@72.37.252.18</a><span style="font-family:courier new,monospace;color:rgb(0,153,0)"> set(open=true)</span><br style="font-family:courier new,monospace;color:rgb(0,153,0)">
</font><br>Note: I added the color so that you could see which dialplan lines correspond to the log output.<br><br>The first condition (purple) fails. ({$caller_id_name} has the value &quot;Unknown&quot; which fails the regex test against /^Emerg_/) However, since you have break=&quot;never&quot;, the parser continues on to the next condition inside this extension. Had you done break=&quot;on-false&quot; (or no break attribute) then the parser would have moved on to the next extension in the dialplan.<br>
<br>The second condition (orange) also fails. Again, you have break=&quot;never&quot;, so even though it fails, the parser moves on to the next condition.<br><br>The third condition (green) passes, so the parser adds the &lt;action&gt; to the task list. (Since you have inline=&quot;true&quot; the action gets executed immediately during dialplan parsing instead later on during the &quot;execution phase&quot;.)<br>
<br>In other words, the log output is exactly what I would expect it to be. <br><br>As to your other question about anti-actions in a stack: this also is a common question. It looks like you are trying to do something like this:<br>
<br>IF (cond1 AND cond2 AND cond3) THEN<br>do actions <br>ELSE<br>do other actions<br>ENDIF<br><br>You cannot do this particular construct just with conditions and anti-actions. Instead you&#39;ll need the brand spanking new &quot;regex&quot; syntax mentioned here: <a href="http://wiki.freeswitch.org/wiki/Dialplan_XML#Multiple_Conditions_.28Logical_OR.2C_XOR.29">http://wiki.freeswitch.org/wiki/Dialplan_XML#Multiple_Conditions_.28Logical_OR.2C_XOR.29</a><br>
<br>So, to do what you wanted to do in the second example (in your second post) you could try this:<br><font style="font-family:courier new,monospace" size="1"><br>&lt;condition regex=&quot;all&quot;&gt;<br>  &lt;regex field=&quot;${sip_gateway}&quot; expression=&quot;^${default_provider}$&quot;/&gt;<br>
  &lt;regex field=&quot;${emergency_call}&quot; expression=&quot;^true$&quot;/&gt;<br>  &lt;regex field=&quot;${db(select/emergency/autoanswer)}&quot; expression=&quot;^1$&quot;/&gt;<br>  &lt;!-- the following actions get executed if all regexes PASS --&gt;<br>
   &lt;action application=&quot;set&quot; data=&quot;call_timeout=60&quot;/&gt;<br>   &lt;action application=&quot;set&quot;<br>data=&quot;effective_caller_id_name=${regex(${caller_id_name}|^Emerg(_.*)$|Auto%1)}&quot;/&gt;<br>
   &lt;action application=&quot;set&quot; data=&quot;autoanswered=true&quot;/&gt;<br>   &lt;action application=&quot;answer&quot; data=&quot;&quot;/&gt;<br>   &lt;action application=&quot;set&quot;<br>data=&quot;group_confirm_file=/usr/local/freeswitch/sounds/en/us/callie/emergency/press_to_accept.wav&quot;/&gt;<br>
   &lt;action application=&quot;set&quot; data=&quot;group_confirm_key=1&quot;/&gt;<br>   &lt;action application=&quot;bridge&quot;<br>data=&quot;user/1000@${domain_name},sofia/gateway/1006_7217/${mobile_number}&quot;/&gt;<br>
  &lt;!-- the following anti-actions are executed if any of the regexes FAIL --&gt;<br>   &lt;anti-action application=&quot;set&quot;<br>data=&quot;effective_caller_id_name=${regex(${caller_id_name}|^Emerg(_.*)$|NotAuto%1)}&quot;/&gt;<br>
   &lt;anti-action application=&quot;set&quot; data=&quot;call_timeout=30&quot;/&gt;<br>   &lt;anti-action application=&quot;set&quot; data=&quot;autoanswered=false&quot;/&gt;<br>   &lt;anti-action application=&quot;set&quot;<br>
data=&quot;group_confirm_file=/usr/local/freeswitch/sounds/en/us/callie/emergency/press_to_accept.wav&quot;/&gt;<br>   &lt;anti-action application=&quot;set&quot; data=&quot;group_confirm_key=1&quot;/&gt;<br>   &lt;anti-action application=&quot;bridge&quot;<br>
data=&quot;user/1000@${domain_name},sofia/gateway/1006_7217/${mobile_number}&quot;/&gt;<br>&lt;/condition&gt;<br> </font><br>The &lt;condition regex=&quot;all&quot;&gt; tells the parser, &quot;Hey, execute the &lt;action&gt;&#39;s only if all regexes PASS, otherwise execute any &lt;anti-action&gt;&#39;s&quot;. That should give you what you need. <br>
<br>Hope this helps! <br><br>-Michael<br><br><br><br><div class="gmail_quote">On Sat, Jan 14, 2012 at 7:39 PM, Herman Griffin <span dir="ltr">&lt;<a href="mailto:herman.griffin@gmail.com">herman.griffin@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello everyone,<br>
<br>
In irc SwK said that freeswitch AND operator is lazy. To me this means<br>
that if a condition is set to break=true and it evaluates to FAIL,<br>
then the that break=never will invert the meaning of FAIL; Change it<br>
to a PASS . But why doesn&#39;t break=false behave in this same manner<br>
when there is only a single condition?<br>
<br>
Take this call trace and dialplan for example. I use a single<br>
condition with break=false. However, unlike the stacked conditions,<br>
the action is not executed when the single condition evaluates to<br>
FAIL. Why doesn&#39;t break=never cause the action to be executed in a non<br>
stacked condition?<br>
<br>
Call trace:<br>
<br>
Dialplan: sofia/external/<a href="mailto:Unknown@72.37.252.18">Unknown@72.37.252.18</a> Regex (FAIL)<br>
[emergency_set_variables] ${caller_id_name}(Unknown) =~ /^Emerg_/<br>
break=never<br>
Dialplan: sofia/external/<a href="mailto:Unknown@72.37.252.18">Unknown@72.37.252.18</a> Date/TimeMatch (FAIL)<br>
[emergency_set_variables] break=never<br>
Dialplan: sofia/external/<a href="mailto:Unknown@72.37.252.18">Unknown@72.37.252.18</a> Date/Time Match (PASS)<br>
[emergency_set_variables] break=never<br>
Dialplan: sofia/external/<a href="mailto:Unknown@72.37.252.18">Unknown@72.37.252.18</a> Action set(open=true) INLINE<br>
EXECUTE sofia/external/<a href="mailto:Unknown@72.37.252.18">Unknown@72.37.252.18</a> set(open=true)<br>
<br>
Dialplan:<br>
<br>
&lt;condition field=&quot;${caller_id_name}&quot; expression=&quot;^Emerg_&quot; break=&quot;never&quot;&gt;<br>
    &lt;action application=&quot;set&quot; data=&quot;emergency_call=true&quot; inline=&quot;true&quot;/&gt;<br>
 &lt;/condition&gt;<br>
<br>
 &lt;condition wday=&quot;2-6&quot; time-of-day=&quot;22:00-23:59&quot; break=&quot;never&quot;&gt;<br>
     &lt;action application=&quot;set&quot; data=&quot;open=true&quot; inline=&quot;true&quot;/&gt;<br>
 &lt;/condition&gt;<br>
<br>
 &lt;condition wday=&quot;1,7&quot; time-of-day=&quot;05:00-23:59&quot; break=&quot;never&quot;&gt;<br>
     &lt;action application=&quot;set&quot; data=&quot;open=true&quot; inline=&quot;true&quot;/&gt;<br>
 &lt;/condition&gt;<br>
<br>
-------------------------------------------------<br>
<br>
I also getting confusing behavior with anti-action and stacked<br>
condition. I expect the anti-action to be executed if any of the<br>
stacked conditions evaluates to FAIL. However, in the case below, the<br>
extension simply breaks if any of the condition evaluates to FAIL.<br>
<br>
Call trace:<br>
<br>
Dialplan: sofia/external/<a href="mailto:Unknown@72.37.252.18">Unknown@72.37.252.18</a> parsing<br>
[public-&gt;emergency_bridge] continue=true<br>
Dialplan: sofia/external/<a href="mailto:Unknown@72.37.252.18">Unknown@72.37.252.18</a> Regex (PASS)<br>
[emergency_bridge] ${sip_gateway}(1006_7217) =~ /^1006_7217$/<br>
break=on-false<br>
Dialplan: sofia/external/<a href="mailto:Unknown@72.37.252.18">Unknown@72.37.252.18</a> Regex (FAIL)<br>
[emergency_bridge] ${emergency_call}() =~ /^true$/ break=on-false<br>
Dialplan: sofia/external/<a href="mailto:Unknown@72.37.252.18">Unknown@72.37.252.18</a> parsing<br>
[public-&gt;public_did] continue=false &lt;-- [[MOVES ON TO ANOTHER<br>
EXTENSION WITH EXECUTING THE anti-action]]<br>
<br>
Dialplan:<br>
<br>
&lt;condition field=&quot;${sip_gateway}&quot; expression=&quot;^${default_provider}$&quot;/&gt;<br>
    &lt;condition field=&quot;${emergency_call}&quot; expression=&quot;^true$&quot;/&gt;<br>
<div class="im">    &lt;condition field=&quot;${db(select/emergency/autoanswer)}&quot; expression=&quot;^1$&quot;&gt;<br>
</div><div class="im">      &lt;action application=&quot;set&quot; data=&quot;call_timeout=60&quot;/&gt;<br>
      &lt;action application=&quot;set&quot;<br>
data=&quot;effective_caller_id_name=${regex(${caller_id_name}|^Emerg(_.*)$|Auto%1)}&quot;/&gt;<br>
      &lt;action application=&quot;set&quot; data=&quot;autoanswered=true&quot;/&gt;<br>
      &lt;action application=&quot;answer&quot; data=&quot;&quot;/&gt;<br>
      &lt;action application=&quot;set&quot;<br>
data=&quot;group_confirm_file=/usr/local/freeswitch/sounds/en/us/callie/emergency/press_to_accept.wav&quot;/&gt;<br>
      &lt;action application=&quot;set&quot; data=&quot;group_confirm_key=1&quot;/&gt;<br>
      &lt;action application=&quot;bridge&quot;<br>
data=&quot;user/1000@${domain_name},sofia/gateway/1006_7217/${mobile_number}&quot;/&gt;<br>
<br>
</div><div class="im">      &lt;anti-action application=&quot;set&quot;<br>
data=&quot;effective_caller_id_name=${regex(${caller_id_name}|^Emerg(_.*)$|NotAuto%1)}&quot;/&gt;<br>
      &lt;anti-action application=&quot;set&quot; data=&quot;call_timeout=30&quot;/&gt;<br>
      &lt;anti-action application=&quot;set&quot; data=&quot;autoanswered=false&quot;/&gt;<br>
</div>      &lt;anti-action application=&quot;set&quot;<br>
data=&quot;group_confirm_file=/usr/local/freeswitch/sounds/en/us/callie/emergency/press_to_accept.wav&quot;/&gt;<br>
      &lt;anti-action application=&quot;set&quot; data=&quot;group_confirm_key=1&quot;/&gt;<br>
<div class="im">      &lt;anti-action application=&quot;bridge&quot;<br>
data=&quot;user/1000@${domain_name},sofia/gateway/1006_7217/${mobile_number}&quot;/&gt;<br>
    &lt;/condition&gt;<br>
</div>  &lt;/extension&gt;<br>
<br>
<br>
SwK suggested that I use a script language, which is probably what<br>
I&#39;ll end up doing. However, I&#39;m very interested in understanding why<br>
the scenarios above. Are these bugs or are they just counter intuitive<br>
rules that we must simply memorize?<br>
<br>
Thanks for your input.<br>
<span class="HOEnZb"><font color="#888888">Herman Griffin<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
<br>
On Sat, Jan 14, 2012 at 11:42 AM, Jeff Lenk &lt;<a href="mailto:jeff@jefflenk.com">jeff@jefflenk.com</a>&gt; wrote:<br>
&gt; By putting the break=never you are defeating the &quot;and&quot; processing. Remove<br>
&gt; that.<br>
&gt;<br>
&gt; Move the second group into its own extension.<br>
&gt;<br>
&gt; --<br>
&gt; View this message in context: <a href="http://freeswitch-users.2379917.n2.nabble.com/Stacked-conditions-are-not-acting-like-logical-AND-tp7188082p7188271.html" target="_blank">http://freeswitch-users.2379917.n2.nabble.com/Stacked-conditions-are-not-acting-like-logical-AND-tp7188082p7188271.html</a><br>

&gt; Sent from the freeswitch-users mailing list archive at Nabble.com.<br></div></div></blockquote><br></div><br>