This finishes the changes for making Macro args LOCAL to the call, and allowing users to declare local variables.

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@70461 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Steve Murphy
2007-06-20 20:10:19 +00:00
parent ce2c52d519
commit c1bb0fc34b
9 changed files with 1322 additions and 1225 deletions

View File

@@ -264,6 +264,7 @@ The following are keywords in the AEL language:
\item random
\item goto
\item jump
\item local
\item return
\item break
\item continue
@@ -368,6 +369,7 @@ First, some basic objects
| <eswitches>
| <ignorepat>
| <word> '=' <collected-word> ';'
| 'local' <word> '=' <collected-word> ';'
| ';'
@@ -400,6 +402,7 @@ First, some basic objects
<statement> :== '{' <statements> '}'
| <word> '=' <collected-word> ';'
| 'local' <word> '=' <collected-word> ';'
| 'goto' <target> ';'
| 'jump' <jumptarget> ';'
| <word> ':'
@@ -719,6 +722,49 @@ context blah {
}
\end{verbatim}
You can declare variables in Macros, as so:
\begin{verbatim}
Macro myroutine(firstarg, secondarg)
{
Myvar=1;
NoOp(Myvar is set to ${myvar});
}
\end{verbatim}
\subsection{Local Variables}
In 1.2, and 1.4, ALL VARIABLES are CHANNEL variables, including the function
arguments and associated ARG1, ARG2, etc variables. Sorry.
In trunk (1.6 and higher), we have made all arguments local variables to
a macro call. They will not affect channel variables of the same name.
This includes the ARG1, ARG2, etc variables.
Users can declare their own local variables by using the keyword 'local'
before setting them to a value;
\begin{verbatim}
Macro myroutine(firstarg, secondarg)
{
local Myvar=1;
NoOp(Myvar is set to ${Myvar}, and firstarg is ${firstarg}, and secondarg is ${secondarg});
}
\end{verbatim}
In the above example, Myvar, firstarg, and secondarg are all local variables,
and will not be visible to the calling code, be it an extension, or another Macro.
If you need to make a local variable within the Set() application, you can do it this way:
\begin{verbatim}
Macro myroutine(firstarg, secondarg)
{
Set(LOCAL(Myvar)=1);
NoOp(Myvar is set to ${Myvar}, and firstarg is ${firstarg}, and secondarg is ${secondarg});
}
\end{verbatim}
\subsection{Loops}