I
I
Igor Balyas2016-09-26 17:31:34
Asterisk
Igor Balyas, 2016-09-26 17:31:34

How to get variable from asterisk macro?

How to get a variable from a macro that runs during DIAL?
SOMEVAR is empty in the main context. The same situation is with GoSub.

[incoming]
exten => trunk_78888888888,1,Dial(SIP/trunk_78888888888/79999999999,,gM(example))
exten => trunk_78888888888,2,NoOp(${SOMEVAR})

[macro-example]
exten => s,1,SET(SOMEVAR=456)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
silverjoe, 2016-09-26
@ihorbalias

If the channel is the same, then the variable will have a value, if the channel is different, then resp. will be empty.
Act as you have already been suggested, or you can still use SHARED, but for this you need to clearly understand which channel you are currently in when processing the dialplan.

F
fluffybear, 2016-09-26
@fluffybear

Use variable inheritance: voip.rus.net/tiki-index.php?page=Asterisk%20Variables
exten => s,1,SET(__SOMEVAR=456)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question