Summary: | ASTERISK-13954: expressions are not working | ||
Reporter: | John Lange (johnlange) | Labels: | |
Date Opened: | 2009-04-14 14:54:36 | Date Closed: | 2011-06-07 14:07:59 |
Priority: | Minor | Regression? | No |
Status: | Closed/Complete | Components: | Functions/func_math |
Versions: | Frequency of Occurrence | ||
Related Issues: | |||
Environment: | Attachments: | ||
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? | ||
Comments: | By: Jared Smith (jsmith) 2009-04-14 15:10:40 John, You'll get that warning if ${TRIES} doesn't yet have a value, as the expression ends up evaluating to: $[1 + ] or $[ + 1] (depending on the order of your operands). What the warning is saying in plain English is "Hey, I got to the end of the expression, but I was expecting something else before the end". To double-check your variable, try this instead: exten => i,2,Verbose(1,The value of TRIES is ${TRIES}.) exten => i,3,Set(TRIES=$[${TRIES}+1]) exten => i,4,Verbose(1,The value of TRIES is now ${TRIES}.) By: Ronald Chan (loloski) 2009-04-14 15:16:49 John, I can't reproduce your issue, i will attach my sample dialplan please take a look. anyway i'm on 1.4 SVN branch. i might overlook on what you are trying to accomplish i might be wrong here too but anyway... exten => *99,1,Set(COUNT=0) exten => *99,n,Set(COUNT=$[${COUNT}+1]) exten => *99,n,GotoIf($[${COUNT} > 3]?15) exten => *99,n,Noop(DEBUG: Login Try ${COUNT}) exten => *99,n,Read(agentnumber|agent-user) exten => *99,n,Read(agentpass|agent-pass) exten => *99,n,Set(AGENTNAME=${ODBC_GET_AGENTNAME(${agentnumber},${agentpass})}) exten => *99,n,Noop(DEBUG: Agent Name -> ${AGENTNAME}) exten => *99,n,GotoIf($["${AGENTNAME}" = ""]?2) exten => *99,n,PauseQueueMember(queue|Sip/${agentnumber}) exten => *99,n,Playback(agent-pause) exten => *99,n,Hangup() By: John Lange (johnlange) 2009-04-14 16:03:53 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. By: Tilghman Lesher (tilghman) 2009-04-14 16:34:48 Not really. Remember that expressions can just as easily be strings. See the regex stuff. In any case, this is not a bug, so I'm closing. |