[Asterisk-Users] line numbering and gosub
Steven Critchfield
critch at basesys.com
Sun Aug 24 23:03:08 MST 2003
On Sun, 2003-08-24 at 14:46, John Brown wrote:
> Hi list,
>
> been playing with * for a bit now and have found at
> least two things that make it difficult.
>
> 1. priority numbers in extensions.conf
>
> This line numbering gig can be a PIA. While I under-
> stand there needs to be a way to branch control (ergo
> goto), it would seem that line numbering is tied to
> 1,2,3,4 as in
>
> exten => s,1,doblah
> exten => s,2,dofi
> exten => s,3 gogetalife
> exten => s,4 goto(s,2)
>
> now if you want to insert something you have to renumber
> all of the lines below, ICK comes to mind.
>
> So I figured I'd try
>
> exten => s,10,doblah
> exten => s,15,dofi
> exten => s,20,gogetalife
> exten => s,25,goto(s,15)
>
> but this doesn't seem to work at all. * just barfs on the
> the call.
>
> I would think that * would read these lines in and order them
> as I've labled them. the * code should do :
>
> when calling an exten: goto first line in the link list of
> lines
>
> when executing a goto: goto the node that matches the label, or
> create a quicky hash of lables -> node pointers to match quickly
It isn't so much for the goto's that it matters, but for error
conditioning. Currently some things like dial will jump to n+101 when
there was an error, and just n+1 when everything is fine.
BTW, I don't know if this is just something in my vimrc, or even if you
are used to using vim, but ctrl-a while your cursor is on a number will
increment it up by 1. It even works when it needs to add new digits in
like going from 9 to 10. Makes it real easy to follow the priority down
through a section pressing ctrl-a and not fumbling for the numbers.
Beware that if you use screen, screen will swallow up your ctrl-a unless
you have reconfigured it to something else.
> The second item:
>
> It would be nice to have a Gosub type command. That
> way you could pop off to a standard strain of code, even
> nest a bit and then by the magic of a stack pop back to
> previous parts......
You need to learn about macros. Macros allow you to make a generic
section of extensions and call it with information about what it is to
be doing. Basically a gosub is a cheap way of making unnamed
subroutines, why not use the macro stuff as better subroutines.
--
Steven Critchfield <critch at basesys.com>
More information about the asterisk-users
mailing list