O'Reilly logo

Asterisk: The Future of Telephony by Leif Madsen, Jared Smith, Jim Van Meggelen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

Eval() — Evaluates any Asterisk variables located within a string

Synopsis

    Eval(newvar=string)

Processes the given string and evaluates any variables contained in the string. The resulting value is assigned to the variable newvar.

This application is used in situations where a string is used in the dialplan, but any variables contained within it need to be evaluated first. This is often the case when the string is retrieved from a database or other external source.

    ; go through some convoluted steps to create a string that contains
    ; the unparsed variable ${UNIQUEID}
    exten => 123,1,Set(ONE=\$)
    exten => 123,2,Set(TWO=$[{UNIQUEID}])
    ; print the values to the console, to make sure it hasn't been parsed
    exten => 123,3,NoOp(${ONE}${TWO})
    ; now evaluate the variables in the string
    exten => 123,4,Eval(TEST=${ONE}${TWO})
    ; print the result to the console
    exten => 123,5,NoOp(${TEST})

See Also

Exec(), ExecIf()

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required