<html>
<head>
    <base href="https://wiki.asterisk.org/wiki">
            <link rel="stylesheet" href="/wiki/s/en/2172/18/9/_/styles/combined.css?spaceKey=AST&amp;forWysiwyg=true" type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://wiki.asterisk.org/wiki/display/AST/Asterisk+11+Application_Macro">Asterisk 11 Application_Macro</a></h2>
    <h4>Page  <b>added</b> by             <a href="https://wiki.asterisk.org/wiki/display/~wikibot">Wiki Bot</a>
    </h4>
         <br/>
    <div class="notificationGreySide">
         <h1><a name="Asterisk11Application_Macro-Macro%28%29"></a>Macro()</h1>

<h3><a name="Asterisk11Application_Macro-Synopsis"></a>Synopsis</h3>

<p>Macro Implementation.</p>
<h3><a name="Asterisk11Application_Macro-Description"></a>Description</h3>



<p>Executes a macro using the context macro- <em>name</em>, jumping to the <tt>s</tt> extension of that context and executing each step, then returning when the steps end.</p>

<p>The calling extension, context, and priority are stored in <tt>MACRO_EXTEN</tt>, <tt>MACRO_CONTEXT</tt> and <tt>MACRO_PRIORITY</tt> respectively. Arguments become <tt>ARG1</tt>, <tt>ARG2</tt>, etc in the macro context.</p>

<p>If you Goto out of the Macro context, the Macro will terminate and control will be returned at the location of the Goto.</p>

<p>If <tt>MACRO_OFFSET</tt> is set at termination, Macro will attempt to continue at priority MACRO_OFFSET + N + 1 if such a step exists, and N + 1 otherwise.</p>
<div class='panelMacro'><table class='warningMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/wiki/images/icons/emoticons/forbidden.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td><b>Warning</b><br />Because of the way Macro is implemented (it executes the priorities contained within it via sub-engine), and a fixed per-thread memory stack allowance, macros are limited to 7 levels of nesting (macro calling macro calling macro, etc.); It may be possible that stack-intensive applications in deeply nested macros could cause asterisk to crash earlier than this limit. It is advised that if you need to deeply nest macro calls, that you use the Gosub application (now allows arguments like a Macro) with explict Return() calls instead.</td></tr></table></div>
<div class='panelMacro'><table class='warningMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/wiki/images/icons/emoticons/forbidden.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td><b>Warning</b><br />Use of the application <tt>WaitExten</tt> within a macro will not function as expected. Please use the <tt>Read</tt> application in order to read DTMF from a channel currently executing a macro.</td></tr></table></div>


<h3><a name="Asterisk11Application_Macro-Syntax"></a>Syntax</h3>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>Macro(namearg1arg2[...])</pre>
</div></div>
<h5><a name="Asterisk11Application_Macro-Arguments"></a>Arguments</h5>


<ul>
        <li>name - The name of the macro</li>
        <li>args
        <ul>
                <li>arg1</li>
                <li>arg2</li>
        </ul>
        </li>
</ul>


<h3><a name="Asterisk11Application_Macro-SeeAlso"></a>See Also</h3>


<ul>
        <li><a href="/wiki/pages/createpage.action?spaceKey=AST&amp;title=Asterisk+11+Application_MacroExit&amp;linkCreation=true&amp;fromPageId=20187015" class="createlink">Asterisk 11 Application&#95;MacroExit</a></li>
        <li><a href="/wiki/pages/createpage.action?spaceKey=AST&amp;title=Asterisk+11+Application_Goto&amp;linkCreation=true&amp;fromPageId=20187015" class="createlink">Asterisk 11 Application&#95;Goto</a></li>
        <li><a href="/wiki/pages/createpage.action?spaceKey=AST&amp;title=Asterisk+11+Application_Gosub&amp;linkCreation=true&amp;fromPageId=20187015" class="createlink">Asterisk 11 Application&#95;Gosub</a></li>
</ul>


<h3><a name="Asterisk11Application_Macro-ImportVersion"></a>Import Version</h3>

<p>This documentation was imported from Asterisk Version SVN-trunk-r370322</p>
    </div>
    <div id="commentsSection" class="wiki-content pageSection">
       <div style="float: right;" class="grey">
                        <a href="https://wiki.asterisk.org/wiki/users/removespacenotification.action?spaceKey=AST">Stop watching space</a>
            <span style="padding: 0px 5px;">|</span>
                <a href="https://wiki.asterisk.org/wiki/users/editmyemailsettings.action">Change email notification preferences</a>
</div>
       <a href="https://wiki.asterisk.org/wiki/display/AST/Asterisk+11+Application_Macro">View Online</a>
              |
       <a href="https://wiki.asterisk.org/wiki/display/AST/Asterisk+11+Application_Macro?showComments=true&amp;showCommentArea=true#addcomment">Add Comment</a>
           </div>
</div>
</div>
</div>
</div>
</body>
</html>