[asterisk-users] Macros, Background(), Return Values...
Yuan LIU
yliu11 at hotmail.com
Thu Feb 22 12:33:17 MST 2007
>From: Doug Garstang <dgarstan at talkplus.com>
>Date: Thu, 22 Feb 2007 10:17:20 -0800
>
>I am programming a very large dialplan right now (Asterisk 1.4), and a
>couple of things are annoying the heck out of me.
I have not programmed large dial plans, but have encountered some of the
nuances.
>1. When in a macro, background() does not work properly. If you use the
>background() app inside a macro, and then press a key, execution returns
>back to the calling context where it tries to match that extension. I
>believe this is a known bug.
Or feature? I posted this question before and haven't got an answer. It
might be a feature on the premise that a macro is not a context. (Even
though I can use Goto to wander inside.)
>2. Is there any way to have macros return a value? I can pass arguments to
>macro's with ARG1..ARGN, but the only way to set a return variable is to
>set a channel variable. Essentially, I have a large number of global
>variables which is never good.
In my wild experimentation, I tried to
Goto(${MACRO_CONTEXT},${return_value},1). But another way to do this is to
abandon macro and use Local channel. Expect to set all necessary _variables
yourself before dialing into a local channel.
>3. If you use Gosub to and Return to jump into and out of contexts, and use
>them like macros to get around the background() problem, the global
>variable issue becomes worse as there's no way to explicitly pass variables
>to the contexts when you do this.
Local channel may be your friend.
>4.Every time you make a decision, you have to use GotoIf, which means more
>code to do simple things like set variables, or do things based on a
>decision. It would be great if there was SetIf(), MacroIf(), or even doIf()
>applications.
Have you looked at AEL?
Yuan Liu
>Has anyone tried to program large complex dialplans before and come across
>some of these issues? How did you resolve them?
>
>Doug.
More information about the asterisk-users
mailing list