[asterisk-users] AEL question: testing channel variables

Philipp Kempgen philipp.kempgen at amooma.de
Sat Jan 10 12:53:27 CST 2009


Klaus Darilion schrieb:
> I use the following condition:
> 
> if (${FOOBAR}=YES) {
>    ...
> }
> 
> The problem is, that if FOOBAR is not defined at all Asterisk generates 
> a warning:
> 
> WARNING[11982]: ast_expr2.fl:407 ast_yyerror: ast_yyerror():  syntax 
> error: syntax error, unexpected '=', expecting $end; Input:
> =YES
> 
> 
> Of course I could use the following code, but this bloats up the code:
> 
> 
> if (${EXISTS(${FOOBAR})}) {
>    if (${FOOBAR}=YES) {
>      ...
>    }
> }
> 
> 
> Is there another syntax to have nice looking code but avoid the warning?

if ("${FOOBAR}"="YES") {
   ...
}

or

if (x${FOOBAR}=xYES) {
   ...
}


   Philipp Kempgen

-- 
AMOOCON 2009, May 4-5, Rostock / Germany   ->  http://www.amoocon.de
Asterisk: http://the-asterisk-book.com - http://das-asterisk-buch.de
AMOOMA GmbH - Bachstr. 126 - 56566 Neuwied  ->  http://www.amooma.de
Geschäftsführer: Stefan Wintermeyer, Handelsregister: Neuwied B14998
-- 



More information about the asterisk-users mailing list