${MACRO_CONTEXT} For Subroutines

Home » Asterisk Users » ${MACRO_CONTEXT} For Subroutines
Asterisk Users 1 Comment

Hello Everybody,

in past times I used macros but since a while they are deprecated. So I replaced my macros with subroutines. In most cases this is really no problem.

But in some rare cases I miss the macro channel variables (e.g.
${MACRO_CONTEXT}). https://wiki.asterisk.org/wiki/display/AST/Dialplan+Macros+Channel+Variables

Is there something similar for subroutines?

Kind regards Bastian

One thought on - ${MACRO_CONTEXT} For Subroutines

  • Howdy

    Due to the nature of GoSub() vs. Macro() there is no built in channel variable which carries that information with a GoSub(). Devs keep me honest here.

    If the subroutine needs to know what part of dialplan the channel came from I recommend sending the information as an ARG in the nested set of parenthesis when executing the GoSub() application.

    exten => _7XXX,1,GoSub(subDialer,begin,1(${CONTEXT}))

    exten => begin,1,Verbose(0, This subroutine was executed from the ${ARG1}