[asterisk-users] vars in Macros called by DIAL with option M

Tilghman Lesher tilghman at mail.jeffandtilghman.com
Tue Aug 5 14:13:15 CDT 2008


above the original post is very confusing.  Please stop doing this.
The format of this post is in reverse, to demonstrate why posting a reply

option is only in trunk.  So no, it would not help him out.
Yes, it works the same way, by using the U() option to Dial.  However, this
Question 2:

prior to the origination of the slave channel.
channel.  No inheritance is possible, because the master channel originated
channel, so any values set in the slave channel will not affect the master
"Apple".  The variable is only set in the slave channel, not in the master
Question 1:

On Tuesday 05 August 2008 11:50:28 Al Baker wrote:
> Err - Ok - let me ask this in MUCH simpler way
>
> 1 - In dialplan , you set a Variable called   "MYVAR", to "Apple"
>
> 2 - You go into MACRO and NOOP the VALUE of "MYVAR" -What SHOULD it BE ?
>
> 3 - While IN MACRO you set VALUE of "MYVAR" = "Pear"
>
> 4 - You leave MACRO and get back to DIALPLAN and NOOP the value of MYVAR
> - What should it be
>
> =========== 2nd Question  ===
>  CAN the DIAL command call a SUBROUTINE instead of a MACRO ?
>
> If so WOULD that help him out ?
>
> Any clarification much apprecatted
>
> Tilghman Lesher wrote:
> > On Tuesday 05 August 2008 10:47:34 Thomas Winter wrote:
> >> Hi all,
> >>
> >> Iam using an DIAL Command wird Macro if callee is answer the call.
> >>
> >> exten => 123,n,DIAL(SIP/123 at provider,180,gM(test_connect))
> >> exten => 123,n,NoOp( ${var_from_macro})
> >>
> >>
> >> In Macro test_connect Iam generating an new variable var_from_macro and
> >> would like to use this var in the original dialplan.
> >> I tried also __var_from_macro but didnt work. How can I set vars in
> >> macros called by DIAL so that I can use these vars in the Dialplan or in
> >> the h extention.
> >
> > There isn't any good way to do that, period.  When it comes to
> > inheritance, variables are only inherited from a master channel to a
> > slave channel.  In the case of the Macro operating within the Dial, that
> > Macro is occurring exclusively on the slave channel.  You cannot directly
> > set variables on other channels (for obvious race-condition reasons).
> >
> > However, you could do this in a roundabout way, either by using a
> > database or by using shared variables in trunk.  You'd need to first set
> > (in the master channel, before the Dial) an inherited variable containing
> > the name of the master channel, i.e. Set(_masterchan=${CHANNEL(name)}),
> > then use that inherited variable to set the shared variable in the master
> > channel from the slave channel, i.e. Set(SHARED(foo,${masterchan})=...). 
> > Finally, you would be able to access the shared variable in the master
> > channel with ${SHARED(foo)}.  Again, the SHARED function is only
> > available in trunk at this time, although you could probably backport it
> > to 1.4 with minimal trouble.
>
> _______________________________________________
> -- Bandwidth and Colocation Provided by http://www.api-digital.com --
>
> AstriCon 2008 - September 22 - 25 Phoenix, Arizona
> Register Now: http://www.astricon.net
>
> asterisk-users mailing list
> To UNSUBSCRIBE or update options visit:
>    http://lists.digium.com/mailman/listinfo/asterisk-users



-- 
Tilghman



More information about the asterisk-users mailing list