[asterisk-users] Howto create variable from the name of another one and get content of it

Administrator TOOTAI admin at tootai.net
Thu Mar 21 16:30:34 CDT 2013


Le 21/03/2013 20:27, Steve Edwards a écrit :
> On Thu, 21 Mar 2013, Administrator TOOTAI wrote:
>
>> I have a variable created like
>>
>> ... Set(__myVar=${ARG1})
>> ... Set(__${myVar}STATUS=)
>>
>> If ARG1 is abcd, variable is abcdSTATUS and should be empty. This is OK.
>>
>> Now I would like to get the value of abcdSTATUS. How to do it? 
>> ${${myVar}STATUS}} isn't working, nor ${{myvar}STATUS}
>
> If 'variable is abcdSTATUS and should be empty' what value are you 
> trying to get?
>
> In your first try '${${myVar}STATUS}}' you have 1 too many closing 
> brace. In your second try '${{myvar}STATUS}' you're missing a 'dollar.'
>
> Is this what you are trying to do?
>
>         exten = *,n,    set(ARG1=abcd)
>         exten = *,n,    set(__myVar=${ARG1})
>         exten = *,n,    set(__${myVar}STATUS=status)
>         exten = *,n,    verbose(myVar = ${myVar})
>         exten = *,n,    verbose(dollar{myVar}STATUS = ${${myVar}STATUS})
>         exten = *,n,    hangup()

Exactly, and this is working.

I found the problem, it's (I think) a bug with queue command. My dialplan:

[context]
...
exten => 33123,n,macro(unpauseQueueMembers,q820,104,105,136,,)
exten => 33123,n(back2Queue),Queue(${myQueue},nit,,,14400)
exten => 33123,n,NoOp(Queue ${myQueue} call status is ${QUEUESTATUS} - 
Dial status is ${DIALSTATUS} - Our status is ${${myQueue}STATUS})  ; 
value is empty
exten => 33123,n,GotoIf($["${${myQueue}STATUS}" = "myTIMEOUT"]?back2Queue)

[to-q820]

exten => 104,1,Dial(SIP/${EXTEN},,Tt)
exten => 105,1,Dial(SIP/${EXTEN},,Tt)
exten => 136,1,Dial(SIP/${EXTEN},,Tt)
exten => _XXX,2,macro(queueCallStatus,${EXTEN})

[macro-queueCallStatus]

exten => s,1,Set(__myExten=${ARG1})
    same => n,NoOp(Call status to ${myExten}@${myQueue} is ${DIALSTATUS})
    same => n,GotoIf($["${DIALSTATUS}" = "ANSWER"]?exitMacro)
    same => n,GotoIf($["${DIALSTATUS}" != "NOANSWER"]?Pause)
    same => n(exitMacro),MacroExit
...
    same => 
n(Pause),NoOp(PauseQueueMember(,Local/${myExten}@to-${myQueue}))
    same => n,Set(__${myQueue}STATUS=myTIMEOUT)
    same => n,NoOp(Value of my variable is ${${myQueue}STATUS})          
                          ; here I get correct value
...
[macro-unpauseQueueMembers]

exten => s,1,Set(__myQueue=${ARG1})
    same => n,Set(__${myQueue}STATUS=)
    same => n,UnpauseQueueMember(,Local/${ARG2}@to-${myQueue})
    same => n,UnpauseQueueMember(,Local/${ARG3}@to-${myQueue})
    same => n,UnpauseQueueMember(,Local/${ARG4}@to-${myQueue})

If I 33123  the NoOp(Value of my variable is ${${myQueue}STATUS}) in 
macro-queueCallStatus shows the right value which is text myTIMEOUT. But 
this value isn't anymore present in
NoOp(Queue ${myQueue} call status is ${QUEUESTATUS} - Dial status is 
${DIALSTATUS} - Our status is ${${myQueue}STATUS}) from [context] which 
is *after* the queue cmd exit.

This is Asterisk 10.11.1. Can someone confirm before opening a bug?

-- 
Daniel



More information about the asterisk-users mailing list