Eval $[...] always returning 0?


#1

Hi,
I’m trying to write some scripts for the dialplan but I’m failing on something really bottom level. See this stripped down example:

[macro-test]
exten => s,1,Set(AA=1)
exten => s,2,Set(AA=${AA}+1)
exten => s,3,Set(AA=1)
exten => s,4,Set(AA=$[${AA}+1])
exten => s,5,Set(BB=${ARG1:1:3})
exten => s,6,Set(CC=999)
exten => s,7,GotoIf($["${BB}" = “${CC}”] ? 50 : 10 )
exten => s,10,Saydigits(“111111”);
exten => s,50,Saydigits(“9999999”);
exten => s,90,Hangup()

[default]
exten => _0999X,1,Macro(test,+${EXTEN:1})

now see the debug output when calling 09999
– Executing Macro(“SIP/+1-6921”, “test|+9999”) in new stack
– Executing Set(“SIP/+1-6921”, “AA=1”) in new stack
– Executing Set(“SIP/+1-6921”, “AA=1+1”) in new stack
– Executing Set(“SIP/+1-6921”, “AA=1”) in new stack
– Executing Set(“SIP/+1-6921”, “AA=0”) in new stack
– Executing Set(“SIP/+1-6921”, “BB=999”) in new stack
– Executing Set(“SIP/+1-6921”, “CC=999”) in new stack
– Executing GotoIf(“SIP/+1-6921”, "0 ? 50 : 10 ") in new stack
– Goto (macro-test,s,10)
– Executing SayDigits(“SIP/+1-6921”, "“111111"”) in new stack

As you can see, the evaluation of AA in Set(AA=$[${AA}+1]) is returning 0 instead of 2 and the comparision of BB with CC is also 0. In other words $[ … ] is ALWAYS returning zero where it should return the result.

PS: This was with: Asterisk CVS HEAD 2005-11-07 13:01:51 UTC


#2

The problem went away in 1.2rc2 but is present in 1.2rc1.


#3

no)
you must write like this
$[ “${A}” != "${B} ]
(add some spaces )
in my configuration working… on rc1