Peter Beckman
2006-May-17 12:54 UTC
[Asterisk-Users] Variable Inheritance - Set in Child, Read by Parent
Here's what I'm doing: 1. I set __FOO=0 in the current context. 2. I use Dial() and the M(testvar) macro call. 3. The macro-testvar can see ${FOO} just fine. 4. the macro-testvar modifies FOO. I tried: Set(__FOO=1) Set(_FOO=1) Set(FOO=1) 5. When the Dial()ed call hangs up, and the original context continues, FOO is still 0. I want it to contain 1, or whaver the child macro-testvar sets it to. Question: 1. Can I modify variables set in the parent context in the child context and read them again in the parent context? 2. Is there a better way to hand back "status" of a Macro executed by the Dial() command? Beckman --------------------------------------------------------------------------- Peter Beckman Internet Guy beckman@purplecow.com http://www.purplecow.com/ ---------------------------------------------------------------------------
Kevin P. Fleming
2006-May-17 13:06 UTC
[Asterisk-Users] Variable Inheritance - Set in Child, Read by Parent
Peter Beckman wrote:> 1. Can I modify variables set in the parent context in the child > context and read them again in the parent context?Not 'context', 'channel'. The macro you are supplying is running on an outbound channel created by the Dial() application, so the simple answer is no, there is no way for the code running on that channel to modify variables owned by the channel that created it.> 2. Is there a better way to hand back "status" of a Macro executed by > the Dial() command?It's possible that MACRO_RESULT might get passed back, I'm not sure.
Peter Beckman
2006-May-17 13:24 UTC
[Asterisk-Users] Variable Inheritance - Set in Child, Read by Parent
Thanks for the fast reply, Kevin! On Wed, 17 May 2006, Kevin P. Fleming wrote:> Peter Beckman wrote: > >> 1. Can I modify variables set in the parent context in the child >> context and read them again in the parent context? > > Not 'context', 'channel'. The macro you are supplying is running on an > outbound channel created by the Dial() application, so the simple answer > is no, there is no way for the code running on that channel to modify > variables owned by the channel that created it.Can I set a channel variable in say IAX2/100104 from IAX2/100105? Is there potentially another way, other than say writing a file to disk in the macro and reading that file in the parent? That's the best I could come up with... :-( I guess I could also set a Global variable called FOO_${CHANNEL}, pass that name to the macro, have it set the Global variable, then destroy it once I read it in the parent. I was hoping for a cleaner option...>> 2. Is there a better way to hand back "status" of a Macro executed by >> the Dial() command? > > It's possible that MACRO_RESULT might get passed back, I'm not sure.But MACRO_RESULT must be CONTINUE in order for the Macro to hang up on the dialed party and continue through the parent context; if I set it to 1, 2, 3 or 4, when the Macro reaches its end, the Macro will connect the call, which is not the intended action. I've poured over the docs, README.variables, some of the doxygen docs, the wiki, and it doesn't seem there is an easy way to do this. Thanks for the quick reply Kevin! Beckman --------------------------------------------------------------------------- Peter Beckman Internet Guy beckman@purplecow.com http://www.purplecow.com/ ---------------------------------------------------------------------------
Mojo with Horan & Company, LLC
2006-May-17 15:21 UTC
[Asterisk-Users] Variable Inheritance - Set in Child, Read by Parent
Would making FOO a global variable help in this situation? Peter Beckman wrote:> Here's what I'm doing: > > 1. I set __FOO=0 in the current context. > > 2. I use Dial() and the M(testvar) macro call. > > 3. The macro-testvar can see ${FOO} just fine. > > 4. the macro-testvar modifies FOO. I tried: > > Set(__FOO=1) > Set(_FOO=1) > Set(FOO=1) > > 5. When the Dial()ed call hangs up, and the original context continues, > FOO is still 0. I want it to contain 1, or whaver the child > macro-testvar sets it to. > > Question: > > 1. Can I modify variables set in the parent context in the child > context and read them again in the parent context? > > 2. Is there a better way to hand back "status" of a Macro executed by > the Dial() command? > > Beckman > --------------------------------------------------------------------------- > Peter Beckman Internet Guy > beckman@purplecow.com http://www.purplecow.com/ > --------------------------------------------------------------------------- > _______________________________________________ > --Bandwidth and Colocation provided by Easynews.com -- > > Asterisk-Users mailing list > To UNSUBSCRIBE or update options visit: > http://lists.digium.com/mailman/listinfo/asterisk-users >-- Mojo <mojo@horanappraisals.com> Office Manger, Horan & Company, LLC (907) 747-6666 x112
Damon Estep
2006-May-17 22:53 UTC
[Asterisk-Users] Variable Inheritance - Set in Child, Read by Parent
CHANNEL variables are lost when the CHANNEL is hung up and torn down, so while you can pass the variable "down" by setting it with the double underscore, it will not be set when you start at the "top" again. There might be other ways to accomplish your goal, one would be to use a global variable that is unique to each session. I have no idea if there is additional overhead required to pass global variables around, but there should not be. http://www.voip-info.org/wiki/index.php?page=Asterisk+cmd+SetGlobalVar> -----Original Message----- > From: asterisk-users-bounces@lists.digium.com [mailto:asterisk-users- > bounces@lists.digium.com] On Behalf Of Peter Beckman > Sent: Wednesday, May 17, 2006 1:55 PM > To: asterisk-users@lists.digium.com > Subject: [Asterisk-Users] Variable Inheritance - Set in Child, Read by > Parent > > Here's what I'm doing: > > 1. I set __FOO=0 in the current context. > > 2. I use Dial() and the M(testvar) macro call. > > 3. The macro-testvar can see ${FOO} just fine. > > 4. the macro-testvar modifies FOO. I tried: > > Set(__FOO=1) > Set(_FOO=1) > Set(FOO=1) > > 5. When the Dial()ed call hangs up, and the original context > continues, > FOO is still 0. I want it to contain 1, or whaver the child > macro-testvar sets it to. > > Question: > > 1. Can I modify variables set in the parent context in the child > context and read them again in the parent context? > > 2. Is there a better way to hand back "status" of a Macroexecuted by> the Dial() command? > > Beckman >------------------------------------------------------------------------ --> - > Peter BeckmanInternet> Guy > beckman@purplecow.com > http://www.purplecow.com/ >------------------------------------------------------------------------ --> - > _______________________________________________ > --Bandwidth and Colocation provided by Easynews.com -- > > Asterisk-Users mailing list > To UNSUBSCRIBE or update options visit: > http://lists.digium.com/mailman/listinfo/asterisk-users