[Asterisk-Users] match a set of numbers in GoToIf against a variable

John Millican john at millican.us
Fri Oct 14 18:41:53 MST 2005


On Friday October 14 2005 8:57 pm, John Millican wrote:
> On Friday October 14 2005 8:26 pm, Samy Antoun wrote:
> > --- John Millican <john at millican.us> wrote:
> > > Hello all,
> > > Okay when you are done laughing at the simplicity of
> > > this question could
> > > someone show me please what I have wrong in the
> > > following statement?
> > > GoToIf($[${numdial} != [1-9] ]?15:3);
> > > What this is supposed to do is if numdial is not a
> > > single digit from 1 to 9
> > > inclusive goto 15, if it is a singledigit from 1 to
> > > 9 inclusive goto 3.
> > > Should be pretty simple but not working for me,
> > > always goes to 15.  from what
> > > I read on the wiki this should work, but obviously I
> > > must have read it wrong.
> > >
> > > I can get this to work:
> > > exten => 1,2, GoToIf($[${numdial} = 1 ]?15:3);
> > > exten => 1,3, GoToIf($[${numdial} = 2 ]?15:4);
> > > exten => 1,4 ,GoToIf($[${numdial} = 3 ]?15:5);
> > > ...
> > > exten => 1,15, do other stuff
> > > but I don't want to put this in 9 times.
> > >
> > > Thanks in advance,
> > > John M
> >
> > John,
> >
> > Will this meet your needs:
> >
> > exten => _Z,1,Will match any single digit from 1 to 9
> > exten => i,1,will match enything else (invalid)
>
> thanks for the reply but i am not sure if that will work. Let me try and
> see. _______________________________________________

Well just for finality, I ended up using len 
GoToIf($[${len(${numdial})} = 1 ]?15:3);
works like a charm.
John M



More information about the asterisk-users mailing list