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()

Get Asterisk: The Future of Telephony now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.