[asterisk-users] AEL question: testing channel variables
Allann Jones
allanjos at gmail.com
Sun Jan 11 20:30:42 CST 2009
http://www.voip-info.org/wiki-Asterisk+variables
http://www.voip-info.org/wiki-Asterisk+Dialplan+Globals
Beware with the variable scope, if its scope is local the values can
be lost, so declare the variable as global when its value must persist
between calls.
[globals]
FOOBAR => NO
[some_context]
if (${FOOBAR}=YES) {
...
}
On Sat, Jan 10, 2009 at 2:53 PM, Philipp Kempgen
<philipp.kempgen at amooma.de> wrote:
> 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
> --
>
> _______________________________________________
> -- 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
>
--
_______________________________
Allann J. O. Silva
"I received the fundamentals of my education in school, but that was
not enough. My real education, the superstructure, the details, the
true architecture, I got out of the public library. For an
impoverished child whose family could not afford to buy books, the
library was the open door to wonder and achievement, and I can never
be sufficiently grateful that I had the wit to charge through that
door and make the most of it." (from I. Asimov, 1994)
More information about the asterisk-users
mailing list