[asterisk-users] Reasons to use AEL (was: Re: Goto from a feature macro is not working?)
Philipp Kempgen
philipp.kempgen at amooma.de
Sat Jul 25 06:03:27 CDT 2009
Miguel Molina schrieb:
> Philipp Kempgen escribió:
>> Use macros in AEL so you don't have to care about the underlying
>> implementation. :-) scnr
> Right now for every implementation I made, I didn't have the need to
> program in AEL, only plain extensions, some AMI and AGI. But well, it
> seems to have a lot of advantages. Please tell me some, I may take a
> look to it too see if it's worth spending the time to learn and get the
> best out of it.
I'd say control structures (and proper indentation) are one of the
most important reasons to use AEL (conditionals: if .. else, switch
.. case, ..., loops: for, while) because they look so familiar.
Imagine nested "control structures" in extensions.conf with Goto(),
GotoIf(), While(), EndWhile(), ExitWhile(), ContinueWhile() and
priorities - such code is not what I call maintainable.
== extensions.conf:
exten => 30,1,Set(x=5)
exten => 30,n,While($[${x} <= 9])
exten => 30,n,NoOp(x ist ${x})
exten => 30,n,ExecIf($[${x} > 5],ExitWhile)
exten => 30,n,Playback(beep)
exten => 30,n,Set(x=$[${x} + 1])
exten => 30,n,EndWhile()
exten => 30,n,NoOp(done)
== extensions.ael:
30 => {
x=0;
while (${x} <= 9) {
NoOp(x ist ${x});
if (${x} > 5) {
break;
}
Playback(beep);
y=${x} + 1;
}
NoOp(done);
}
In this example, we needed more lines in AEL; if we had added another
command to the if condition in our while loop, ExecIf() would not be
enough anymore and we would be forced to use a more complex construc-
tion with GotoIf(). Our extensions.conf would be a lot longer.
Philipp Kempgen
--
AMOOMA GmbH - Bachstr. 126 - 56566 Neuwied -> http://www.amooma.de
Geschäftsführer: Stefan Wintermeyer, Handelsregister: Neuwied B14998
Asterisk: http://the-asterisk-book.com - http://das-asterisk-buch.de
Videos of the AMOOCON VoIP conference 2009 -> http://www.amoocon.de
--
More information about the asterisk-users
mailing list