Link to home
Start Free TrialLog in
Avatar of Silas2
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..

Open in new window

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
Avatar of Phonebuff
Phonebuff
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Silas2
Silas2

ASKER

I think that looks like it..., let me just see.
Avatar of Silas2

ASKER

I'm doing as you suggested, but I'm getting " Sent to invalid extension 'Provider1'
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)

Open in new window

Avatar of Silas2

ASKER

I'm on 1,8, can I use the exten=>textLable,priority,  in 1.8?
Avatar of Silas2

ASKER

I don't want to sound ungrateful, but your code:
extern=>  s,n,GoToIf(MyVAr  = 3? Provider3,1)

Open in new window

the syntax is slightly wrong!!! it should be:

extern=>  s,n,GoToIf(MyVAr  = 3?: Provider3,1)
extra colon when only one if-then!!!

Open in new window

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.

    =============
Avatar of Silas2

ASKER

Sorry, you are right and i am indeed a numpty. True part before colon. just wasted an hour on that.....!