The variable ${CONTEXT} stores the value of the current context. However if we are in a macro that will be the name of the macro. How do I access the name of the local channel's context. For example: [macro-test] exten => s,n,NoOp(Context ${CONTEXT}) CLI shows: -- Executing NoOp("Local/2592@1100006-2000-e802,2", "Context macro-test") in new stack I want to get 1100006-2000 somehow. Any suggestions would be appreciated. Cameron ___________________________________________________________ The all-new Yahoo! Mail goes wherever you go - free your email address from your Internet provider. http://uk.docs.yahoo.com/nowyoucan.html -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20070226/3927ce71/attachment.htm
Tzafrir Cohen
2007-Feb-26 21:42 UTC
[asterisk-users] How to get values of local channels context
On Mon, Feb 26, 2007 at 08:06:40PM -0800, kjcsb wrote:> The variable ${CONTEXT} stores the value of the current context. However if we are in a macro that will be the name of the macro. How do I access the name of the local channel's context. > > For example: > [macro-test] > exten => s,n,NoOp(Context ${CONTEXT}) > > CLI shows: > -- Executing NoOp("Local/2592@1100006-2000-e802,2", "Context macro-test") in new stack > > I want to get 1100006-2000 somehow. > > Any suggestions would be appreciated.>From the text of 'show application macro':[Description] Macro(macroname|arg1|arg2...): Executes a macro using the context 'macro-<macroname>', jumping to the 's' extension of that context and executing each step, then returning when the steps end. The calling extension, context, and priority are stored in ${MACRO_EXTEN}, ${MACRO_CONTEXT} and ${MACRO_PRIORITY} respectively. Arguments become ${ARG1}, ${ARG2}, etc in the macro context. So use ${MACRO_CONTEXT} . -- Tzafrir Cohen icq#16849755 jabber:tzafrir@jabber.org +972-50-7952406 mailto:tzafrir.cohen@xorcom.com http://www.xorcom.com iax:guest@local.xorcom.com/tzafrir
Lee Jenkins
2007-Feb-26 21:43 UTC
[asterisk-users] How to get values of local channels context
kjcsb wrote:> The variable ${CONTEXT} stores the value of the current context. However > if we are in a macro that will be the name of the macro. How do I access > the name of the local channel's context. > > For example: > [macro-test] > exten => s,n,NoOp(Context ${CONTEXT}) > > CLI shows: > -- Executing NoOp("Local/2592@1100006-2000-e802,2 > <mailto:Local/2592@1100006-2000-e802,2>", "Context macro-test") in new stack > > I want to get 1100006-2000 somehow. >Hi, Check out ${MACRO_CONTEXT} http://www.voip-info.org/wiki/index.php?page=Asterisk+cmd+Macro -- Warm Regards, Lee
>> CLI shows: >> -- Executing NoOp("Local/2592@1100006-2000-e802,2", "Context macro-test") in new stack >> >> I want to get 1100006-2000 somehow. >> >> Any suggestions would be appreciated. > >So use ${MACRO_CONTEXT} .Thanks But doesn't this give the calling context which, if itself is another macro, will still not give me what I want? If macro-test is called by macro-first then ${MACRO_CONTEXT} = macro-first. Surely there's a way to get the context directly from the Local channel itself? Cameron ___________________________________________________________ Inbox full of unwanted email? Get leading protection and 1GB storage with All New Yahoo! Mail. http://uk.docs.yahoo.com/nowyoucan.html -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20070226/e40cc3e0/attachment-0001.htm
>Check out /path/to/src/asterisk/doc/README.variables${DIALEDPEERNUMBER} would give it to me if I sliced it up. exten => s,n,Set(Foo=${CUT(DIALEDPEERNUMBER,@,2)}) exten => s,n,Set(Foo=${CUT(Foo,/n,1)}) Are there any better options? Cameron ___________________________________________________________ New Yahoo! Mail is the ultimate force in competitive emailing. Find out more at the Yahoo! Mail Championships. Plus: play games and win prizes. http://uk.rd.yahoo.com/evt=44106/*http://mail.yahoo.net/uk -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20070228/ddec2026/attachment.htm
>>Check out /path/to/src/asterisk/doc/README.variables>${DIALEDPEERNUMBER} would give it to me if I sliced it up. >exten => s,n,Set(Foo=${CUT(DIALEDPEERNUMBER,@,2)}) >exten => s,n,Set(Foo=${CUT(Foo,/n,1)})${CHANNEL} gets me something similar. Too bad I now have to rename my contexts. Putting a - in them makes using Cut with ${CHANNEL} difficult! Cameron ___________________________________________________________ The all-new Yahoo! Mail goes wherever you go - free your email address from your Internet provider. http://uk.docs.yahoo.com/nowyoucan.html -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20070228/00ca7ac5/attachment.htm
Yuan LIU
2007-Feb-28 22:24 UTC
[asterisk-users] How to get values of local channels context
>From: kjcsb <kjcsb@yahoo.com> >Date: Wed, 28 Feb 2007 18:23:46 -0800 (PST) > > >Check out /path/to/src/asterisk/doc/README.variables > >${DIALEDPEERNUMBER} would give it to me if I sliced it up. >exten => s,n,Set(Foo=${CUT(DIALEDPEERNUMBER,@,2)}) >exten => s,n,Set(Foo=${CUT(Foo,/n,1)}) > >Are there any better options? > >CameronThis is beautiful. How much better can it get? Syntax-wise, you can combine the two lines into one because the value of CUT() can be used inside another function including CUT(). Using inheritable variable could be an alternative. But efficiency difference is neglegible. Yuan Liu
Yuan LIU
2007-Mar-01 01:39 UTC
[asterisk-users] How to get values of local channels context
>From: "Yuan LIU" <yliu11@hotmail.com> >Date: Wed, 28 Feb 2007 21:24:56 -0800 > >>From: kjcsb <kjcsb@yahoo.com> >>Date: Wed, 28 Feb 2007 18:23:46 -0800 (PST) >> >> >Check out /path/to/src/asterisk/doc/README.variables >> >>${DIALEDPEERNUMBER} would give it to me if I sliced it up. >>exten => s,n,Set(Foo=${CUT(DIALEDPEERNUMBER,@,2)}) >>exten => s,n,Set(Foo=${CUT(Foo,/n,1)}) >> >>Are there any better options? >> >>Cameron > >This is beautiful. How much better can it get? Syntax-wise, you can >combine the two lines into one because the value of CUT() can be used >inside another function including CUT(). Using inheritableTake this back; CUT expects a variable name, not a value:-(>variable could be an alternative. But efficiency difference is neglegible. > >Yuan Liu