Hi, Is there some more thorough documentation of this change that has happened in 1.6? The upgrade.txt and changes.txt files mention it, but I have already seen details of this change that do not appear to be documented except in conversations on the mailing list... 1) It appears that it is no longer legal to have: [macro-contaxtA] ...stuff... [contextA] ...stuff... Is this true? Or have I misunderstood the post that I read? 2) The single most useful feature of a macro was auto-return on unmatched goto. This feature reduces the size of my dialplan to about 30% of its previous size! How can this be implemented with a Gosub? eg. [macro-specialcases] exten => s,1,Goto(c-${ARG1}) exten => c-special,1,NoOp(I am special) The above would execute the NoOp if ARG1 is set to "special" but just return otherwise. Perhaps a Gosub can use the 'i' extension to do the same? [macro-specialcases] exten => s,1,Goto(c-${ARG1}) exten => c-special,1,NoOp(I am special) exten => c-special,2,Return exten => i,2,Return Perhaps? Thanks for any pointers. Regards, Steve
Tilghman Lesher
2009-Apr-29 14:20 UTC
[asterisk-users] Replacement of Macro() with Gosub()
On Wednesday 29 April 2009 07:27:44 Steve Davies wrote:> Hi, > > Is there some more thorough documentation of this change that has > happened in 1.6? The upgrade.txt and changes.txt files mention it, but > I have already seen details of this change that do not appear to be > documented except in conversations on the mailing list... > > 1) It appears that it is no longer legal to have: > > [macro-contaxtA] > ...stuff... > > [contextA] > ...stuff... > > Is this true? Or have I misunderstood the post that I read?You've misunderstood. Gosub does not use the "macro-" prefix, and indeed, there's no requirement that your gosub target even be a separate context. You can have a gosub target be a high priority within your current extension (this would probably be most appropriate when your extension is a wide-ranging pattern match).> 2) The single most useful feature of a macro was auto-return on > unmatched goto. This feature reduces the size of my dialplan to about > 30% of its previous size! How can this be implemented with a Gosub? > > eg. > > [macro-specialcases] > exten => s,1,Goto(c-${ARG1}) > exten => c-special,1,NoOp(I am special) > > The above would execute the NoOp if ARG1 is set to "special" but just > return otherwise. Perhaps a Gosub can use the 'i' extension to do the > same?It cannot. Your Goto must match something, and you will never return without an explicit Return(). Let's also be clear about what Gosub is replacing. Gosub replaces Macro for AEL2. The side effects of this are relatively unfelt, unless you're doing something unusual like defining subroutines in AEL and calling them from extensions.conf. The big gain in this is the ability to have infinite depths of subroutines, as opposed to a maximum of about 7 in 1.4's AEL. Macro is not going away. If you want to continue to use Macro, it's there for you to use, warts and all. Macro continues to have the depth limit of 7 levels deep, and that won't change. It's a fundamental limit of the application, which is one of the reasons why its functionality has been replaced in AEL with Gosub. Also, I think Gosub is a bit easier to learn, and its behavior is more straightforward. There aren't corner cases and special behaviors that you have to learn about Gosub; it just works like a subroutine. -- Tilghman