Simple variable inheritance issue

Maybe I don’t understand variable inheritance, but I have a context [A] which contains the DIAL command which uses the “U” option to jump to context [B] upon call “answer” (or connect, however you like to put it).

So here is what I did:

  1. In Context [A] I created a variable __XYZ and set it to 1234, using SET(__XYZ=1234)
  2. When call answered, in Context [B] when I do NoOP(${XYZ}), I see 1234
  3. When I do SET(XYZ=6789) in context [B], and do a NoOP(${XYZ}) after that, I see the variable now change to 6789
  4. At the end of the context[B], I do a return, which will continue the procedure back to context [A] after call hangs
  5. When the script jump back to context [A], the variable {XYZ} still only 1234, not 6789

Why is that? So it seems the inheritance only travels “one direction”? From parent to child only? And whatever child do to that variable STAYS in child only, does not pass back to parent?

So if that is the case, how can I pass a variable from child to parent?

I am using Asterisk 11


_ed variables are copied when a channel is created. Your subroutine is running on a new channel, with a copy of the original variable, so any changes are local to that channel.

You should use Shared variable for your purpose.
Look at here for some more information … ion_SHARED

–Satish Barot