[Asterisk-Users] AEL #include
Michael Collins
mcollins at fcnetwork.com
Tue May 30 21:28:17 MST 2006
> How would goto work if all the priorities where n?
...
> Example from one of my dial plans:
>
> exten => talk,1,ForkCDR
> exten => talk,n,Set(NUMTRIES=1)
> exten => talk,n,GotoIf($[${NUMTRIES} = 1]?first)
> exten => talk,n(repeat),Background(Initial-greeting)
> exten => talk,n(first),Wait(.1)
> exten => talk,n,Festival(${fname})
> exten => talk,n,Festival(${lname})
> exten => talk,n,Background(If-person1)
> exten => talk,n,GotoIf($[${NUMTRIES} < 2]?repeat)
> exten => talk,n,Set(NUMTRIES=$[${NUMTRIES}+1])
> exten => talk,n,Goto(t,1)
>
Doug,
Like Kevin said, the label takes the place of the hard-numbered
priorities. In the example of my "talk" extension, I have a pair of
GotoIf() commands. This particular extension is used for an
experimental voice-broadcasting system that I'm playing with.
As you can see, the first priority is hard-coded as '1' but each
subsequent priority is simply 'n'. It starts at 1, does the ForkCDR,
then moves on to the next priority. Since there is no '2' priority, it
simply moves to the next 'n' priority the extension. In this case, it
just sets my NUMTRIES variable then moves to the next 'n' priority,
which is the first of the two GotoIf() commands. Notice the "first"
after the ? in the GotoIf(). Instead of putting in a numbered priority,
I put in a label. In this case, the GotoIf() is saying, "If this is the
first attempt, i.e. NUMTRIES equals 1, then goto the priority labeled
'first', otherwise just move on to the next priority." If NUMTRIES is
'1' then the GotoIf sends the processing to this priority:
exten => talk,n(first),Wait(.1)
>From there the processing continues.
I have a feeling that if you aren't using labels and you have many
Goto()'s and GotoIf()'s then you'll LOVE labels. Once you get your
labels in place you will almost never have to renumber your priorities.
Check this out for more info:
http://www.voip-info.org/wiki/index.php?page=Asterisk%20priorities
Specifically the info under the 'n' priorities. I know that there's
some info on this in the TFOT book but I can't find it right now. But I
highly recommend that you check out using labels and 'n' priorities - it
will decrease your blood pressure significantly!
-MC
More information about the asterisk-users
mailing list