[asterisk-users] Howto create variable from the name of another one and get content of it
Richard Mudgett
rmudgett at digium.com
Thu Mar 21 17:46:59 CDT 2013
> > 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.
The the parent channel (the incoming channel on exten 33123) sets the
variable to empty. A child channel (Dialed by app Queue) running a
local channel in the context [to-q820] sets the variable to the status
you are wanting. The child cannot send that variable value back to the
parent channel. Channel variable inheritance only goes one way: from
parent to child.
Richard
More information about the asterisk-users
mailing list