<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body bgcolor="#ffffff" text="#000000">
Watkins, Bradley wrote:
<blockquote
id="mid_9674CD468FD230449E116DE0B0E56FF902E52202_nasa-dtw-ex005_nasa_cpwr_corp"
cite="mid:9674CD468FD230449E116DE0B0E56FF902E52202@nasa-dtw-ex005.nasa.cpwr.corp"
type="cite">
<blockquote id="StationeryCiteGenerated_1" type="cite">
<pre wrap="">________________________________
        From: <a class="moz-txt-link-abbreviated" href="mailto:asterisk-users-bounces@lists.digium.com">asterisk-users-bounces@lists.digium.com</a>
</pre>
</blockquote>
<pre wrap=""><!---->[<a class="moz-txt-link-freetext" href="mailto:asterisk-users-bounces@lists.digium.com">mailto:asterisk-users-bounces@lists.digium.com</a>] On Behalf Of Brent
Davidson
</pre>
<blockquote id="StationeryCiteGenerated_2" type="cite">
<pre wrap="">        Sent: Wednesday, December 31, 2008 1:03 PM
        To: <a class="moz-txt-link-abbreviated" href="mailto:murf@digium.com">murf@digium.com</a>; Asterisk Users Mailing List -
</pre>
</blockquote>
<pre wrap=""><!---->Non-Commercial Discussion
</pre>
<blockquote id="StationeryCiteGenerated_3" type="cite">
<pre wrap="">        Subject: Re: [asterisk-users] AEL Variable Warning Messages
        Well, before I file a bug I have another question... In AEL,
</pre>
</blockquote>
<pre wrap=""><!---->what is the correct syntax? Do all variable references still need to be
wrapped in ${} or not? If they do, then the documentation on
voip-info.org needs to be changed to reflect that.
Yes, variable references need to be wrapped in ${}. Where on the wiki
do you see an example that is otherwise? I just looked at the main
documentation for AEL, and I didn't see any instances of it. Certainly
they can and should be fixed if they are there.
</pre>
<blockquote id="StationeryCiteGenerated_4" type="cite">
<pre wrap="">        
        Beyond that, what are the rules for putting the values assigned
</pre>
</blockquote>
<pre wrap=""><!---->to variables in quotes? In my example above, at one point I had a space
between the = and the Zap/r2 statement with no quotes. The value
assigned to TRUNK then included a leading space. I didn't test to see
whether or not putting a space after the variable name adds a space to
the variables name. I would think that any spaces after an operator
should be ignored unless the come after a single or double quote.
The rules are that there aren't any really. Neither a single- nor
double-quote have any specific meaning in the sense of signifying a
string. I'm also curious to know where you saw an example of assignment
that used quotes of any kind, since I can't find that either.
Regards,
- Brad
</pre>
</blockquote>
Both the AEL and AEL2 examples include the following examples in the
"Variables" section:<br>
<br>
---HTML Copied from WIKI page
<a class="moz-txt-link-freetext" href="http://www.voip-info.org/wiki/view/Asterisk+AEL">http://www.voip-info.org/wiki/view/Asterisk+AEL</a>---<br>
<h2>Variables
</h2>
Variables in Asterisk do not have a type, so to define a variable, it
just has to be specified with a value.
<br>
<br>
Global variables are set in their own block.
<br>
<br>
<div class="bitbox"><span style="font-family: monospace;">globals {
</span><br>
<span style="font-family: monospace;"> CONSOLE=Console/dsp;
</span><br>
<span style="font-family: monospace;"> TRUNK=Zap/g2;
</span><br>
<span style="font-family: monospace;">};</span></div>
<br>
<strong>NOTE:</strong> The opening curly-brace must appear as above.
Moving it to the following line may have disastrous consequences!
<br>
<br>
Variables can be set within extensions as well.
<br>
<br>
<div class="bitbox"><br>
<span style="font-family: monospace;">context foo {
</span><br>
<span style="font-family: monospace;"> 555 => {
</span><br>
<span style="font-family: monospace;"> x=5;
</span><br>
<span style="font-family: monospace;"> y=blah;
</span><br>
<span style="font-family: monospace;"> divexample=10/2
</span><br>
<span style="font-family: monospace;"> NoOp(x is ${x} and y is ${y} !);
</span><br>
<span style="font-family: monospace;"> };
</span><br>
<span style="font-family: monospace;">};</span></div>
<br>
<br>
<strong>NOTE:</strong> Asterisk beta1 parses assignments using a
$[] wrapper as opposed to the more logical way of doing it like Set and
SetVar work. In this example, I had ${ARG1} set to "SIP/x7065558529"
sans-quotes and it flunked out. <br>
<strong>NOTE:</strong> Another opinion: The $[ ] allow
expressions to be used, and add extra power to the language. Read the
README.variables about the requirements of $<a
href="http://www.voip-info.org/wiki/view/Asterisk+AEL"> </a>
expressions. In the following example, the SIP/x7065558529
<br>
<span style="font-family: monospace;"> should not be "sans quotes". So, the statement might have been entered: requesting_channel="${ARG1}"; ( where the ""'s prevent the evaluation. )
</span><br>
<strong>NOTE:</strong> These things are wrapped up in a $[
] expression: The while() test; the if() test; the middle expression in
the for( x; y; z) statement (the y expression); Assignments — the right
hand side, so a = b -> Set(a=$[b])
<br>
<br>
<span style="font-family: monospace;"> requesting_channel=${ARG1}
</span><br>
ERROR: Oct 10 12:48:59 WARNING[19726]: ast_expr2.y:811 op_div:
non-numeric argument
<br>
<span style="font-family: monospace;"> — Executing Set("SIP/x7065558529-2afd", "requesting_channel=0") in new stack
</span><br>
FROM show dialplan:
<br>
<span style="font-family: monospace;"> 's' => 1. Set(requesting_channel=$[ ${ARG1} ]) [pbx_ael]
</span><br>
<br>
But you can use Set and it works the old way.
<br>
<br>
<span style="font-family: monospace;"> Set(requesting_channel=${ARG1})
</span><br>
<br>
<br>
Writing to a dialplan function is treated the same as writing to a
variable.
<br>
<br>
<div class="bitbox"><br>
<span style="font-family: monospace;">context blah {
</span><br>
<span style="font-family: monospace;"> s => {
</span><br>
<span style="font-family: monospace;"> CALLERID(name)=ChickenMan;
</span><br>
<span style="font-family: monospace;"> NoOp(My name is ${CALLERID(name)} !);
</span><br>
<span style="font-family: monospace;"> };
</span><br>
<span style="font-family: monospace;">}; </span></div>
<br>
---END HTML Copied from WIKI---<br>
<br>
I see the line about using the old Set syntax, but the examples and the
rest of the notes imply that that you could just do x=5; rather than
${x}=5; and get the same result either way.<br>
<br>
Another question along these lines... If I set a Global called "TRUNK"
in the globals section and later assign do a TRUNK=whatever it appears
that a local variable called TRUNK is created instead of using the
global. You must explicitly use the Set(GLOBAL(TRUNK)=whatever) syntax
to alter the global.<br>
<br>
As far as the quotes go, I resorted to using them in an effort to get
rid of that extra space at the beginning of my value. I just figured
that if the examples were wrong on one aspect that maybe they were off
in other ways as well.<br>
<br>
The examples in the "Macros" and "Conditionals" sections of AEL shows
the variables with the curly brace syntax, but the "loops" section uses
both syntaxes in it's examples.<br>
<br>
I would be happy to help clean up the examples on the wiki as long as
I'm sure I know what I'm doing. As for my dialplan, I've reverted to
using the Set(VAR=whatever) syntax since it's less likely to do
something unexpected.<br>
</body>
</html>