Re: [asterisk-users] AEL question: testing channel variables

2009-01-11 Thread Allann Jones
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
 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)

___
-- 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


Re: [asterisk-users] AEL question: testing channel variables

2009-01-10 Thread Philipp Kempgen
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


Re: [asterisk-users] AEL question: testing channel variables

2009-01-08 Thread Brent Vrieze
Initialize FOOBAR to some know value (ie NO) and change it when you need 
to.  Then it will always be defined.

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?
>
> thanks
> klaus
>
> ___
> -- 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
>
>
>   

___
-- 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


Re: [asterisk-users] AEL question: testing channel variables

2009-01-08 Thread Steve Murphy
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 
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

Re: [asterisk-users] AEL question: testing channel variables

2009-01-08 Thread Julian Lyndon-Smith
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?
>   

How about

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

Julian
> thanks
> klaus
>
> ___
> -- 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
>
>   


__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
__

___
-- 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


[asterisk-users] AEL question: testing channel variables

2009-01-08 Thread Klaus Darilion
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?

thanks
klaus

___
-- 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