[SOLVED] Setting variables in dial option subroutines

For some reason I can set a variable with multiple inheritance in a dial option subroutine using b() or B(), however, if I use U() I cannot (and G() while not a subroutine, behaves like U().

Oddly enough, I can read the variable ${TESTVARIABLE} in all situations, b(), B(), U() and G(), however in U() or G() with a Set(__TESTVARIABLE=value) – it never gets properly set outside of the subroutine.

I’m curious if this is a bug, as it doesn’t behave the same way in all scenarios. Any other input, regarding if it’s meant to be this way, or if it is a bug, how to file a report, would be appreciated.

For reference, I am using Asterisk 11.2-cert2.

Here’s my example:

; -------------- Test with this command:
; asterisk*CLI> channel originate LOCAL/s@myinbound application wait 3
 
[myinbound]
 
exten => s,     1,Noop(my inbound context)
same =>         n,Set(__TESTVARIABLE=consider this unset)
; --------- Next line didn't work (TESTVARIABLE remains unchanged after execution)
same =>         n,Dial(LOCAL/100@fakecall,,U(subTest))
; --------- Next line DID work. (TEST Variable gets changed in the subroutine)
; same =>               n,Dial(LOCAL/100@fakecall,,B(subTest^s^1))
 
exten => h,     1,Noop(Hangup in my inbound context)
same =>         n,Noop(My test variable: ${TESTVARIABLE})
 
[fakecall]
 
exten => 100,1,Noop(Entered the fake call)
same =>         n, Answer()
same =>         n, Hangup()
 
exten => h,     1,Noop(Hangup in fake call context)
same =>         n,Noop(My test variable: ${TESTVARIABLE})
 
[subTest]
 
exten => s,1,Noop(into the sub)
same => n,Noop(${TESTVARIABLE} <-- that's my test variable)
same => n,Set(__TESTVARIABLE=this is properly set)
same => n,return

U runs on the called channel; nothing inherits from that, for a normal call. b and B are too new for my version. G runs on both called and calling channels. If you set on the called channel, the same applies as for U.

David – thank you for the eyeballs, appreciate it.

With some help from the freenode channel, I realized that U() is operating on a new channel, as opposed to the original channel. So what I wound up doing was using a SHARED(variable)=value and then passing the ${CHANNEL} to the subroutine as an argument.

Here’s my solution that sound up working:

[code][myinbound]

exten => s, 1,Noop(my inbound context)
same => n,Set(SHARED(__TESTVARIABLE)=consider this unset)
; This will work, passing the channel and setting it as a shared channel variable.
same => n,Dial(LOCAL/100@fakecall,U(subTest^${CHANNEL}))

exten => h, 1,Noop(Hangup in my inbound context)
same => n,Noop(My test variable: ${SHARED(TESTVARIABLE)})

[fakecall]

exten => 100, 1,Noop(Into the fake call…)
same => n, Answer()
same => n, Wait(3)
same => n, Hangup()

[subTest]

exten => s, 1,Noop(into the sub)
same => n,Noop(${SHARED(TESTVARIABLE,${ARG1})} <-- that’s my test variable [before])
same => n,Set(SHARED(TESTVARIABLE,${ARG1})=this is properly set)
same => n,Noop(${SHARED(TESTVARIABLE,${ARG1})} <-- that’s my test variable [after])
same => n,return
[/code]