[asterisk-users] AEL Variable Warning Messages

Brent Davidson brent at texascountrytitle.com
Mon Jan 5 14:42:37 CST 2009


Watkins, Bradley wrote:
>> ________________________________
>>
>> 	From: asterisk-users-bounces at lists.digium.com
>>     
> [mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of Brent
> Davidson
>   
>> 	Sent: Wednesday, December 31, 2008 1:03 PM
>> 	To: murf at digium.com; Asterisk Users Mailing List -
>>     
> Non-Commercial Discussion
>   
>> 	Subject: Re: [asterisk-users] AEL Variable Warning Messages
>>
>> 	Well, before I file a bug I have another question...  In AEL,
>>     
> 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.
>   
>> 	
>> 	Beyond that, what are the rules for putting the values assigned
>>     
> 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
>   
Both the AEL and AEL2 examples include the following examples in the 
"Variables" section:

---HTML Copied from WIKI page 
http://www.voip-info.org/wiki/view/Asterisk+AEL---


    Variables

Variables in Asterisk do not have a type, so to define a variable, it 
just has to be specified with a value.

Global variables are set in their own block.

globals {
    CONSOLE=Console/dsp;
    TRUNK=Zap/g2;
};

*NOTE:* The opening curly-brace must appear as above. Moving it to the 
following line may have disastrous consequences!

Variables can be set within extensions as well.


context foo {
    555 => {
         x=5;
         y=blah;
         divexample=10/2
         NoOp(x is ${x} and y is ${y} !);
    };
};


*NOTE:* 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.
*NOTE:* Another opinion: The $[ ] allow expressions to be used, and add 
extra power to the language. Read the README.variables about the 
requirements of $ <http://www.voip-info.org/wiki/view/Asterisk+AEL> 
expressions. In the following example, the SIP/x7065558529
                  should not be "sans quotes". So, the statement might have been entered:  requesting_channel="${ARG1}";    ( where the ""'s prevent the evaluation. ) 

*NOTE:* 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])

         requesting_channel=${ARG1}
ERROR: Oct 10 12:48:59 WARNING[19726]: ast_expr2.y:811 op_div: 
non-numeric argument
   --- Executing Set("SIP/x7065558529-2afd", "requesting_channel=0") in new stack 

FROM show dialplan:
 's' =>            1. Set(requesting_channel=$[ ${ARG1} ])       [pbx_ael]

But you can use Set and it works the old way.

         Set(requesting_channel=${ARG1})


Writing to a dialplan function is treated the same as writing to a 
variable.


context blah {
    s => {
         CALLERID(name)=ChickenMan;
         NoOp(My name is ${CALLERID(name)} !);
    };
}; 

---END HTML Copied from WIKI---

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.

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.

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.

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.

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20090105/0e4b9449/attachment.htm 


More information about the asterisk-users mailing list