[asterisk-bugs] [Asterisk 0014897]: expressions are not working
Asterisk Bug Tracker
noreply at bugs.digium.com
Tue Apr 14 16:03:53 CDT 2009
A NOTE has been added to this issue.
======================================================================
http://bugs.digium.com/view.php?id=14897
======================================================================
Reported By: johnlange
Assigned To:
======================================================================
Project: Asterisk
Issue ID: 14897
Category: Functions/func_math
Reproducibility: always
Severity: minor
Priority: normal
Status: new
Asterisk Version: 1.4.23
Regression: No
SVN Branch (only for SVN checkouts, not tarball releases): N/A
SVN Revision (number only!):
Request Review:
======================================================================
Date Submitted: 2009-04-14 14:54 CDT
Last Modified: 2009-04-14 16:03 CDT
======================================================================
Summary: expressions are not working
Description:
In Asterisk 1.4.23.1, expressions don't seem to be working.
According to the docs (doc/channelvariables.txt), you should be able to
do this:
exten => 1,2,Set(koko=$[2 * ${lala}])
In my system I have this:
exten => i,2,Set(TRIES=$[1 + ${TRIES}])
However, it generates this error:
WARNING[6389]: ast_expr2.fl:407 ast_yyerror: ast_yyerror(): syntax
error: syntax error, unexpected $end, expecting '-' or '!' or '(' or
'<token>'; Input:
1 +
^
I also reversed it:
exten => i,2,Set(TRIES=$[${TRIES} + 1])
But it still didn't work.
I know this worked in the past so is there something I'm not seeing or
are expressions not working in Asterisk?
======================================================================
----------------------------------------------------------------------
(0103247) johnlange (reporter) - 2009-04-14 16:03
http://bugs.digium.com/view.php?id=14897#c103247
----------------------------------------------------------------------
Ok, so the problem is the variable has to be initialized before it can be
used in an expression. e.g.:
exten => i,1,Set(TRIES=0)
otherwise it evaluates to "" (not "0" as one might expect) in the
expression which is why it generates a syntax error. Strictly speaking this
is probably not a bug unless it used to work differently in a previous
version which I'm not in a position to confirm.
However, it would be nice if uninitialized variables evaluated to the
numeric "0" when used in expressions since it would simplify dialplans
considerably. Also a note in the documentation about that would be a good
idea.
Issue History
Date Modified Username Field Change
======================================================================
2009-04-14 16:03 johnlange Note Added: 0103247
======================================================================
More information about the asterisk-bugs
mailing list