<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Nov 28, 2015 at 7:14 AM, Ethy H. Brito <span dir="ltr"><<a href="mailto:ethy.brito@inexo.com.br" target="_blank">ethy.brito@inexo.com.br</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
Hi<br>
<br>
I have a 3 level nested while-endwhile loop in a macro that when the<br>
execution reaches endwhile, it is jumping out to the While at the caller<br>
macro.<br>
<br>
It shouldn't since the are instructions after the endwhile.<br>
<br>
    -- Executing [s@macro-call-from-outside:72] EndWhile("DAHDI/i1/1234567-4a7f", "") in new stack<br>
  == Channel 'DAHDI/i1/1234567-4a7f' jumping out of macro 'call-from-outside'<br>
    -- Executing [s@macro-recurse_check_redirect_not_mailbox:7]<br>
    While("DAHDI/i1/1234567-4a7f", "1") in new stack<br>
<br>
I checked the while-endwhile balance and it seems ok.<br>
I also checked if I GoTo() outside the loop. I don't.<br>
<br>
Macroexit is executed inside the while-endwhile loop in certain cases<br>
exiting some inner loop.<br>
<br>
Could MacroExiting inside a while loop cause this lost of balance?<br>
<br clear="all"></blockquote></div><br></div><div class="gmail_extra">Yes it could. A While loop should be terminated with an EndWhile.<br><br></div><div class="gmail_extra">Both the While application as well as the Macro application attempt to control the PBX flow while a channel is executing within them. Terminating an outer container of PBX flow without properly terminating an inner one can inbalance the stack.<br></div><div class="gmail_extra"><br></div><div class="gmail_extra">And just as a reminder, Macros are deprecated. They tend to have odd side effects at times, and overly nesting Macros can result in a crash. You should consider switching to subroutines.<br></div><div class="gmail_extra"><br></div><div class="gmail_extra">Matt</div><div class="gmail_extra"><br>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>Matthew Jordan<br></div><div>Digium, Inc. | Director of Technology<br></div><div>445 Jan Davis Drive NW - Huntsville, AL 35806 - USA</div><div>Check us out at: <a href="http://digium.com" target="_blank">http://digium.com</a> & <a href="http://asterisk.org" target="_blank">http://asterisk.org</a></div></div></div></div></div>
</div></div>