[asterisk-users] While loop inside recursive calls
Ethy H. Brito
ethy.brito at inexo.com.br
Tue Mar 21 12:31:04 CDT 2017
Hi All
What happens if I, inside of a while/endwhile loop, call recursively a
macro that itself has another while/endwhile loop and calls exitwhile() inside the
recursive call?
[macro-recursive]
instance=$ARG1
if instance>3
macroexit
X=1
_var1=""
; recursive loop
while(Dcondition)
_var1=value_${X}
recursive(instance+1)
if var1==""
ExitWhile()
X=X+1
some_Dcondition_changing
bla...
bla...
EndWhile
macroexit
[some_running_context]
; Main loop
while(Zcondition)
recursive(1)
if (var1=="")
ExitWhile
some_Zcondition_changing
bla...
bla...
endwhile
more_intructions
MacroExit
The problem I see is if I reentry "macro-recursive" a the second time,
Macroexit returns to "more_instructions" at "some_running_context" (just after
the Main Loop endWhile). It should return to 'if (var1=="")' at the previous
"macro-recursive" call.
It is like the second call to "macro-recursive" overwrites the first
"macro-recursive" while/endwhile loop return point, and the second ExitWhile
exits from the while/endwhile at "some_running_context" and not from first
"macro-recursive" instance.
In short: second (and subsequent??) call to macro-recursive is ExitWhile()ing
from "some_running_context" while loop. First call exits ok.
Any directions to share?
Is this explanation too complicated to understand?
Regards
Ethy
More information about the asterisk-users
mailing list