[asterisk-users] IF else
Steve Edwards
asterisk.org at sedwards.com
Wed Nov 19 10:51:49 CST 2008
On Wed, 19 Nov 2008, Atis Lezdins wrote:
> 1) Start using AEL (remove this context from extensions.conf and add
> to extensions.ael):
>
> context a2billing {
> _X. => {
> if("${EXTEN}"="111") {
> Playback(AR_GetGiveToID);
> Wait(2);
> Record(/tmp/asterisk-recording:ulaw,,5);
> Wait(2);
> Playback(/tmp/asterisk-recording);
> Wait(2);
> Hangup();
> } else if("${EXTEN}"="112") {
> Playback(AR_GetGiveToID);
> Wait(2);
> Record(/tmp/asterisk-recording:ulaw,,5);
> Wait(2);
> Playback(/tmp/asterisk-recording);
> Wait(2);
> Hangup();
> } else {
> DeadAGI(a2billing.php);
> Wait(2)
> Hangup();
> }
> }
You're missing a couple of "semi-colons."
> 2) Start using extension masks (also works with AEL):
>
> [a2billing]
> exten => _111,1,Noop(Dialled 111)
> exten => _111,n,Playback(AR_GetGiveToID)
> exten => _111,n,Wait(2)
> exten => _111,n,Record(/tmp/asterisk-recording:ulaw,,5)
> exten => _111,n,Wait(2)
> exten => _111,n,Playback(/tmp/asterisk-recording)
> exten => _111,n,Wait(2)
> exten => _111,n,Hangup
>
> exten => _112,1,Noop(Dialed 112)
> exten => _112,n,Playback(AR_GetGiveToID)
> exten => _112,n,Wait(2)
> exten => _112,n,Record(/tmp/asterisk-recording:ulaw,,5)
> exten => _112,n,Wait(2)
> exten => _112,n,Playback(/tmp/asterisk-recording)
> exten => _112,n,Wait(2)
> exten => _112,n,Hangup
>
> exten => _X.,1,Noop(Didn't dial 111 or 112)
> exten => _X.,n,DeadAGI,a2billing.php
> exten => _X.,n,Wait,2
> exten => _X.,n,Hangup
And, just in case the 2 extensions really are supposed to do the exact
same thing, use extension pattern matching:
context a2billing
{
_11[12] =
{
playback(AR_GetGiveToID);
wait(2);
record(/tmp/asterisk-recording:ulaw,,5);
wait(2);
playback(/tmp/asterisk-recording);
wait(2);
hangup();
};
_x. =
{
deadagi(a2billing.php);
wait(2);
hangup();
};
};
(The above is my first attempt at AEL. It parses, but it hasn't actually
been tested.)
I would question the use of deadagi() in a "non-h" extension. Are signals
not being trapped correctly in a2billing.php?
Thanks in advance,
------------------------------------------------------------------------
Steve Edwards sedwards at sedwards.com Voice: +1-760-468-3867 PST
Newline Fax: +1-760-731-3000
More information about the asterisk-users
mailing list