[Asterisk-Users] AEL #include
Douglas Garstang
dgarstang at oneeighty.com
Wed May 31 07:45:38 MST 2006
> -----Original Message-----
> From: Michael Collins [mailto:mcollins at fcnetwork.com]
> Sent: Tuesday, May 30, 2006 10:28 PM
> To: Asterisk Users Mailing List - Non-Commercial Discussion
> Subject: RE: [Asterisk-Users] AEL #include
>
>
> > 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.
Thanks Michael. I was not aware that labels where available.
In converting though, I've already hit a limitation. There's a single name space for all labels I assume?
When you have multiple loops and things of a similar nature, you have to start making you label names unique, to the point where they are no longer simple, and don't make a lot of sense anymore.
More information about the asterisk-users
mailing list