[Asterisk-Dev] Oh what could the if-then-else syntax in AEL b e?

Watkins, Bradley Bradley.Watkins at compuware.com
Wed Jul 6 05:52:14 MST 2005


I believe you have misinterpreted the example.

The example, verbatim, is:

context conditional {
        _8XXX => {
                Dial(SIP/${EXTEN});
                if (${DIALSTATUS} = "BUSY") {
                        Voicemail(${EXTEN}|b);
                } else
                        Voicemail(${EXTEN}|u);
        };
        _777X => {
                switch (${EXTEN}) {
                        case 7771:
                                NoOp(You called 7771!);
                                break;
                        case 7772:
                                NoOp(You called 7772!);
                                break;
                        case 7773:
                                NoOp(You called 7773!);
                                // fall through
                        default:
                                NoOp(In the default clause!);
                };
        };
};

If you start counting the opening and closing brackets you'll quickly
realize that the }; is the delimiter for the extension _8XXX and not for the
if-else clause.  That would be why the first message you got stated you had
too many closing brackets.  In the second try you first delimited the if
clause with }; and then tried to call the application else which obviously
does not exist.

So the actual if-else syntax is:

if ${DIALSTATUS} = "BUSY") {
                         Voicemail(${EXTEN}|b);
		} else
                         Voicemail(${EXTEN}|u);

Hope that helps,
- Brad

-----Original Message-----
From: asterisk-dev-bounces at lists.digium.com
[mailto:asterisk-dev-bounces at lists.digium.com] On Behalf Of Brian Capouch
Sent: Wednesday, July 06, 2005 4:19 AM
To: Asterisk Developers Mailing List
Subject: [Asterisk-Dev] Oh what could the if-then-else syntax in AEL be?


The parser doesn't like the example in README.ael:

if (${DIALSTATUS} = "BUSY") {
                         Voicemail(${EXTEN}|b);
		} else
                         Voicemail(${EXTEN}|u);
         };



Jul  6 03:10:36 WARNING[4125]: pbx_ael.c:129 __grab_token: Syntax error 
at line 18 of 'extensions.ael', too many closing braces!
     -- Added extension 's' priority 7 to macro-std-exten-ael
     -- Added extension 's' priority 8 to macro-std-exten-ael
     -- Added extension 's' priority 6 to macro-std-exten-ael Jul  6
03:10:36 NOTICE[4125]: pbx_ael.c:1114 handle_root_token: Unknown 
root token 'switch(${DIALSTATUS}) '
Jul  6 03:10:36 NOTICE[4125]: pbx_ael.c:1114 handle_root_token: Unknown 
root token 'catch'
Jul  6 03:10:36 WARNING[4125]: pbx_ael.c:129 __grab_token: Syntax error 
at line 33 of 'extensions.ael', too many closing braces!
Jul  6 03:10:36 NOTICE[4125]: pbx_ael.c:1114 handle_root_token: Unknown 
root token '}'

***************

Maybe it should be like C, with an open brace ahead of the else clause:

  if (${DIALSTATUS} = "BUSY") {
                          Voicemail(${EXTEN}|b);
                 } else {
                  Voicemail(${EXTEN}|u)
	};

Parser doesn't like that one, either:
Jul  6 03:12:12 WARNING[4125]: pbx_ael.c:129 __grab_token: Syntax error 
at line 33 of 'extensions.ael', too many closing braces!
******************

So, I can get the parser to shut up if I put a semicolon after the if() 
part statement:
  if (${DIALSTATUS} = "BUSY") {
                          Voicemail(${EXTEN}|b);
                 }; else {
                  Voicemail(${EXTEN}|u);
                 };

(Ahhhh.)

Only problem is, now the parser things the if() statement ends after the 
if() part, so at runtime Asterisk wonders what application "else" might be:
Jul  6 03:14:40 WARNING[4269]: pbx.c:1648 pbx_extension_helper: No 
application 'else' for extension (macro-std-exten-ael, s, 9)

********************

Something is borked, I fear. . . I'm pounding on it, but so far several 
hours of changing things around in extensions.ael still yield me no joy.

B.





_______________________________________________
Asterisk-Dev mailing list
Asterisk-Dev at lists.digium.com
http://lists.digium.com/mailman/listinfo/asterisk-dev
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-dev



The contents of this e-mail are intended for the named addressee only. It
contains information that may be confidential. Unless you are the named
addressee or an authorized designee, you may not copy or use it, or disclose
it to anyone else. If you received it in error please notify us immediately
and then destroy it. 




More information about the asterisk-dev mailing list