## 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=DAHDI/g2;
      }

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: AEL wraps the right hand side of an assignment with $[ ] to allow expressions to be used If this is unwanted, you can protect the right hand side from being wrapped by using the Set() application. Read the README.variables about the requirements and behavior of $[ ] expressions.

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])

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)} !);
          }
      }

You can declare variables in Macros, as so:

-     Macro myroutine(firstarg, secondarg)
      {
        Myvar=1;
        NoOp(Myvar is set to ${myvar});
      }