Silas2
asked on
Asterisk GoToIf else question
I can't get my head round the asterisk gotoif/else. I'm using the 'n' numbering, but i want to do something like this:
switch (MyVar)
{
case 1: exten => s,n,(dial1),Dial(SIP/VoIPProvider1/${dialednum},30,g)
case 2: exten => s,n,(dial2),Dial(SIP/VoIPProvider2/${dialednum},30,g)
case 2: exten => s,n,(dial3),Dial(SIP/VoIPProvider3/${dialednum},30,g)
}
carry on with lots more stuff..
i.e. i don't want to execute a hangup() after each branch, i have a lot of other stuff common to case 1,2,3 i want to add.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I'm doing as you suggested, but I'm getting " Sent to invalid extension 'Provider1'
here's my extensionts.conf:
here's my extensionts.conf:
exten => s,n, GoToIf(${STAT(e,/home/silas/csharp/DialPlanBranches/B1/ChooseMe.txt)}=1 ? Provider1,1 )
exten => s,n, GoToIf(${STAT(e,/home/silas/csharp/DialPlanBranches/B2/ChooseMe.txt)}=1 ? Provider2,1 )
exten => s,n, GoToIf(${STAT(e,/home/silas/csharp/DialPlanBranches/B3/ChooseMe.txt)}=1 ? Provider3,1 )
exten => s,n, GoToIf(${STAT(e,/home/silas/csharp/DialPlanBranches/B4/ChooseMe.txt)}=1 ? Provider4,1 )
exten => s,n, GoToIf(${STAT(e,/home/silas/csharp/DialPlanBranches/B5/ChooseMe.txt)}=1 ? Provider5,1 )
exten => Provider1,1,Dial(SIP/VoIPProvider/${dialednum},30,g)
exten => Provider2,1,Dial(SIP/VoIPProviderSipgate/${dialednum},30,g)
exten => Provider3,1,Dial(SIP/VoIPProvider/${dialednum},30,g)
exten => Provider4,1,Dial(SIP/VoIPProvider/${dialednum},30,g)
exten => Provider5,1,Dial(SIP/VoIPProvider/${dialednum},30,g)
ASKER
I'm on 1,8, can I use the exten=>textLable,priority, in 1.8?
ASKER
I don't want to sound ungrateful, but your code:
extern=> s,n,GoToIf(MyVAr = 3? Provider3,1)
the syntax is slightly wrong!!! it should be:extern=> s,n,GoToIf(MyVAr = 3?: Provider3,1)
extra colon when only one if-then!!!
That was throwing my dialplan out. I am very grateful for seeing the 'named extenstion' way of branching, and you do remember things a bit better when you have to work for them!
Sorry,
I haven't had to write a dial plan context in a few months. Was working from memory.
Glad you got it working.
=============
I haven't had to write a dial plan context in a few months. Was working from memory.
Glad you got it working.
=============
ASKER
Sorry, you are right and i am indeed a numpty. True part before colon. just wasted an hour on that.....!
ASKER