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

Steve Edwards asterisk.org at sedwards.com
Thu Mar 21 14:27:24 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()

-- 
Thanks in advance,
-------------------------------------------------------------------------
Steve Edwards       sedwards at sedwards.com      Voice: +1-760-468-3867 PST
Newline                                              Fax: +1-760-731-3000



More information about the asterisk-users mailing list