[asterisk-users] Macros, GoSub & StackPop

Tilghman Lesher tlesher at digium.com
Tue Feb 23 22:02:34 CST 2010


On Tuesday 23 February 2010 21:35:39 hugolivude wrote:
> Hi -
>
> I have a Macro that contains a GoTo.  The documentation indicates:
>
> If you GoTo out of the Macro context, the Macro will terminate and control
> will return at the location refered to by the Goto.
>
> I thought I might convert the Macro to a GoSub routine, but the
> documentation doesn't mention what happens if you GoTo out.  It does
> however mention that the return address gets pushed onto the stack, so I'm
> a little concerned about the state of the stack if I simply GoTo out. 
> Should I call StackPop first?

Yes, that is the purpose of the StackPop function:  to remove the last stack
frame without returning to the Gosub location.  Note that if you had any
LOCAL() variables (or arguments), those will additionally all be cleared with
the execution of the StackPop application (and the previous values, if any,
will return).

-- 
Tilghman Lesher
Digium, Inc. | Senior Software Developer
twitter: Corydon76 | IRC: Corydon76-dig (Freenode)
Check us out at: www.digium.com & www.asterisk.org



More information about the asterisk-users mailing list