[Asterisk-Users] Variable Inheritance - Set in Child, Read by Parent

Damon Estep damon at suburbanbroadband.net
Wed May 17 22:53:37 MST 2006


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 at lists.digium.com [mailto:asterisk-users-
> bounces at lists.digium.com] On Behalf Of Peter Beckman
> Sent: Wednesday, May 17, 2006 1:55 PM
> To: asterisk-users at 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 Macro
executed by
>         the Dial() command?
> 
> Beckman
>
------------------------------------------------------------------------
--
> -
> Peter Beckman
Internet
> Guy
> beckman at 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



More information about the asterisk-users mailing list