On Thu, 2009-01-08 at 19:24 +0100, Klaus Darilion wrote:
> Hi!
>
> 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?
Klaus--
The simplest I can think of is:
if ("${FOOBAR}"="YES") {
...
}
adding the quotes just makes it so if ${FOOBAR} evaluates to nothing,
then it will still end being a token, and you avoid the syntax error.
You have to keep in mind that by the time the $[ ... ] exprs are evaluated,
all ${..} constructs have been recursively evaluated away.
the wiki is a good reference for AEL2...
(http://voip-info.org/wiki/view/Asterisk+AEL2
and there is a page of example snippets.
murf
>
> thanks
> klaus
--
Steve Murphy <[email protected]>
Digium
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
