Summary:ASTERISK-17089: Dialplan does not work as it should
Reporter:Private Name (falves11)Labels:
Date Opened:2010-12-09 15:42:55.000-0600Date Closed:2011-06-07 14:05:10
Versions:Frequency of
Description:Given a set of global variables GW0=A, GW1=B, etc,, and two integer global variables MXC=0 and MX=1

The following line does not work (erroneously),
exten =>_X.,1,Set(Target=${GW${${RAND(${MXC},${MX})}}})

So I had to break it in 2 separate lines, that do exactly what the first line should do
exten =>_X.,1,Set(junky=${RAND(${MXC},${MX})})
exten =>_X.,n,Set(Target=${GW${junky}})

The goal os to have the variable Target to randomly fluctuate between GW0  and GW1.
I think that the parser is flawed, since both ways to express the logic are correct.

Comments:By: Tilghman Lesher (tilghman) 2010-12-10 11:02:16.000-0600

You have an extra set of braces in there:
exten =>_X.,1,Set(Target=${GW${${RAND(${MXC},${MX})}}})
evaluates to either ${0} or ${1}, which is blank, in both cases.  Thus, it's trying to evaluate ${GW} in the final case, which is blank.  What you actually want is
exten =>_X.,1,Set(Target=${GW${RAND(${MXC},${MX})}})