[asterisk-users] Originate with label?

Antony Stone
Mon, 29 Aug 2022 13:30:15 -0000

On Monday 29 August 2022 at 14:51:27, Mark Murawski wrote:

> On 8/29/22 08:48, Mark Murawski wrote:
> >
> > Hi Antony,
> >
> > I love to hear about AEL use-cases.  I'm happy that AEL is working
out
> > for you.

It is, although there are ways I think it can be improved - I'm wondering
how
best to go about proposing these.

The most obvious for now are:

 - please can "a=1;" be converted to use Set() instead of MSet()
(especially
since MSet is officially deprecated)?

 - same thing for for (;;)

 - please can gosub be added, to convert into Gosub() (matching goto
converting to Goto())?  The & syntax is completely different from the rest
of
the language, and also creates redundant assignments at the start of the
subroutine for parsing the parameters.  Now that macros are deprecated in
favour of subroutines, it makes sense, I think, to make gosub a part of AEL.

 - it would be great if the redundant NoOp()s which get created by if .. else,
while ... and for(;;) could be (maybe optionally?) removed from the resultant
dialplan code - otherwise you end up with lots of added commands such as
NoOp(Finish if_if_fromTrunk_208_209); in the output.

 - finally, it would be good if the documentation could be clear about whether
the extensions.conf [general] section can be substituted using AEL.  I
haven't
yet worked out whether this is possible or not.

> > Without modifying the code for Originate(), you can do this while
> > staying purely in AEL
> > Here's your workaround:
> >
> > context something {
> >   s => {
> >
Originate(Local/${Dest}@Dialout,exten,${CONTEXT},GotoLabel,1,,v(GotoExten
> > =${EXTEN}^GotoLabel=LabelName)); }
> >
> >   GotoLabel => {
> >     goto ${CONTEXT}, ${GotoExten}, ${GotoLabel};
> >   }
> > }

Right, I had wondered about using the v option.  Thanks for the suggestion.

In the meantime I came up with:

Originate(Local/${Dest}@Dialout,exten,${CONTEXT},Orig${EXTEN},1);

_OrigX. => goto ${EXTEN:4},target;

> And, additionally.  You really *should* be breaking down components into
> their own macros or extension blocks.  Adding labels to jump into the
> middle of an extension is typically a sign that you've outgrown your
> overall design.

Oh, I already have plenty of contexts and a fair number of extensions.  I'm
not writing the entire dialplan in one context :)

There's a good reason why I need to jump to another location in the same
context once the Originate has completed.

> It's much. much. much easier to build a system up from different
> contexts,extensions and use goto/gosub and make your system more modular
> instead of having one-giant-context with one-giant-extension that tries
> to do everything.

Very much agreed.


Antony.

--
I conclude that there are two ways of constructing a software design: One way
is to make it so simple that there are _obviously_ no deficiencies, and the
other way is to make it so complicated that there are no _obvious_
deficiencies.

 - C A R Hoare

                                                   Please reply to the list;
                                                         please *don't* CC
me.