[asterisk-users] AEL2 Looping
Russell Bryant
russell at digium.com
Sat Jul 29 11:05:44 MST 2006
----- Douglas Garstang <dgarstang at oneeighty.com> wrote:
> context new_pbx_betty_start {
>
> _X. => {
> for (x=0; ${x} < 3; x=${x} + 1) {
> Verbose(x is ${x} !);
> }
> };
>
> }
>
> Here's the output.
>
> The var x never gets incremented! Is this a bug?
> The while loops seem to work ok.
I would have to see the output of "show dialplan new_pbx_betty_start" to know exactly what is going on. However, I'm guessing that if you remove the space between the semicolon and the "x=${x} + 1", it will work.
On pretty much everything except expression evaluation (such as ${x} < 3), Asterisk is sensitive to whitespace. " x=${x} + 1" was most likely translated directly into Set( x=$[${x} = 1]). That means you are setting the variable name, " x", including the leading space. That is not the same variable as ${x} which you are using everywhere else.
--
Russell Bryant
Software Developer
Digium, Inc.
More information about the asterisk-users
mailing list