Note: This command has been replaced by Asterisk Expressions
exten => s,5,BackGround,blabla
The parameter (blabla) can be quoted ("blabla"). In this case, a comma does not terminate the field.
Also, characters special to variable substitution, expression evaluation, etc (see below), can be quoted. For example, to literally use a $ on the string "$1231", quote it with a preceeding \. Special characters that must be quoted to be used, are $ " \. (to write \ itself, use \\).
To set a variable to a particular value, do :
exten => 1,2,SetVar(varname=value)
You can substitute the value of a variable everywhere using ${variablename}. For example, to stringwise append $lala to $blabla and store result in $koko, do:
exten => 1,2,SetVar(koko=${blabla}${lala})
There are also the following special variables:
There are two reference modes - reference by value and reference by name. To refer to a variable with its name (as an argument to a function that requires a variable), just write the name. To refer to the variable's value, enclose it inside ${}. For example, SetVar takes as the first argument (before the =) a variable name, so:
exten => 1,2,SetVar(koko=lala)
exten => 1,3,SetVar(${koko}=blabla)
stores to the variable "koko" the value "lala" and to variable "lala" the value "blabla". In fact, everything contained ${here} is just replaced with the value of the variable "here".
Everything contained inside a bracket pair prefixed by a $ (like $[this]) is considered as an expression and it is evaluated. Evaluation works similar to (but is done on a later stage than) variable substitution: the expression (including the square brackets) is replaced by the result of the expression evaluation. The arguments and operands of the expression MUST BE separated with spaces (take care NOT to leave ANY spaces between opening and closing square brackets and the first and last arguments).
For example, after the sequence:
exten => 1,1,SetVar,"lala=$[1 + 2]";
exten => 1,2,SetVar,"koko=$[2 * ${lala}]";
the value of variable koko is "6".
Operators are listed below in order of increasing precedence. Operators
with equal precedence are grouped within { } symbols.
expr1 | expr2
Return the evaluation of expr1 if it is neither an empty string
nor zero; otherwise, returns the evaluation of expr2.
expr1 & expr2
Return the evaluation of expr1 if neither expression evaluates to
an empty string or zero; otherwise, returns zero.
expr1 {=, >, >=, <, <=, !=} expr2
Return the results of integer comparison if both arguments are
integers; otherwise, returns the results of string comparison
using the locale-specific collation sequence. ...
GENERAL ENHANCEMENTS TO EXTENSION LOGIC
QUOTING
exten => s,5,BackGround,blabla
The parameter (blabla) can be quoted ("blabla"). In this case, a comma does not terminate the field.
Also, characters special to variable substitution, expression evaluation, etc (see below), can be quoted. For example, to literally use a $ on the string "$1231", quote it with a preceeding \. Special characters that must be quoted to be used, are $ " \. (to write \ itself, use \\).
VARIABLES
Parameter strings can include variables. Variable names are arbitrary strings. They are stored in the respective channel structure.To set a variable to a particular value, do :
exten => 1,2,SetVar(varname=value)
You can substitute the value of a variable everywhere using ${variablename}. For example, to stringwise append $lala to $blabla and store result in $koko, do:
exten => 1,2,SetVar(koko=${blabla}${lala})
There are also the following special variables:
- ${CALLERID} Caller ID
- ${CALLERIDNAME} Caller ID Name only
- ${CALLERIDNUM} Caller ID Number only
- ${EXTEN} Current extension
- ${CONTEXT} Current context
- ${PRIORITY} Current priority
- ${CHANNEL} Current channel name
- ${ENV(VAR)} Environmental variable VAR
- ${EPOCH} Current unix style epoch
- ${DATETIME} Current date time in the format: YYYY-MM-DD_HH:MM:SS
- ${UNIQUEID} Current call unique identifier
- ${SIPDOMAIN} Domain Name for current incomming SIP called, intended for host based routing
There are two reference modes - reference by value and reference by name. To refer to a variable with its name (as an argument to a function that requires a variable), just write the name. To refer to the variable's value, enclose it inside ${}. For example, SetVar takes as the first argument (before the =) a variable name, so:
exten => 1,2,SetVar(koko=lala)
exten => 1,3,SetVar(${koko}=blabla)
stores to the variable "koko" the value "lala" and to variable "lala" the value "blabla". In fact, everything contained ${here} is just replaced with the value of the variable "here".
EXPRESSIONS
Everything contained inside a bracket pair prefixed by a $ (like $[this]) is considered as an expression and it is evaluated. Evaluation works similar to (but is done on a later stage than) variable substitution: the expression (including the square brackets) is replaced by the result of the expression evaluation. The arguments and operands of the expression MUST BE separated with spaces (take care NOT to leave ANY spaces between opening and closing square brackets and the first and last arguments).
For example, after the sequence:
exten => 1,1,SetVar,"lala=$[1 + 2]";
exten => 1,2,SetVar,"koko=$[2 * ${lala}]";
the value of variable koko is "6".
Operators are listed below in order of increasing precedence. Operators
with equal precedence are grouped within { } symbols.
expr1 | expr2
Return the evaluation of expr1 if it is neither an empty string
nor zero; otherwise, returns the evaluation of expr2.
expr1 & expr2
Return the evaluation of expr1 if neither expression evaluates to
an empty string or zero; otherwise, returns zero.
expr1 {=, >, >=, <, <=, !=} expr2
Return the results of integer comparison if both arguments are
integers; otherwise, returns the results of string comparison
using the locale-specific collation sequence. ...




