@ -22,8 +22,8 @@ will be passed down to the Background command, in this example.
Also, characters special to variable substitution, expression evaluation, etc
Also, characters special to variable substitution, expression evaluation, etc
(see below), can be quoted. For example, to literally use a \$ on the
(see below), can be quoted. For example, to literally use a \$ on the
string "\$ 1231", quote it with a preceding \ \ . Special characters that must
string "\$ 1231", quote it with a preceding \ textbackslash . Special characters that must
be quoted to be used, are [ ] \$ " \ \. (to write \\ itself, use \\ ).
be quoted to be used, are [ ] \$ " \ textbackslash. (to write \textbackslash itself, use \textbackslash ).
These Double quotes and escapes are evaluated at the level of the
These Double quotes and escapes are evaluated at the level of the
asterisk config file parser.
asterisk config file parser.
@ -35,7 +35,7 @@ Double quotes can also be used inside expressions, as discussed below.
Parameter strings can include variables. Variable names are arbitrary strings.
Parameter strings can include variables. Variable names are arbitrary strings.
They are stored in the respective channel structure.
They are stored in the respective channel structure.
To set a variable to a particular value, do :
To set a variable to a particular value, do:
\begin { verbatim}
\begin { verbatim}
exten => 1,2,Set(varname=value)
exten => 1,2,Set(varname=value)
\end { verbatim}
\end { verbatim}
@ -97,7 +97,7 @@ If you want to select the first N characters from the string assigned
to a variable, simply append a colon and the number of characters to
to a variable, simply append a colon and the number of characters to
skip from the beginning of the string to the variable name.
skip from the beginning of the string to the variable name.
\begin { verbatim}
\begin { verbatim}
; Remove the first character of extension, save in "number" variable
; Remove the first character of extension, save in "number" variable
exten => _ 9X.,1,Set(number=$ { EXTEN: 1 } )
exten => _ 9X.,1,Set(number=$ { EXTEN: 1 } )
\end { verbatim}
\end { verbatim}
Assuming we've dialed 918005551234, the value saved to the 'number' variable
Assuming we've dialed 918005551234, the value saved to the 'number' variable
@ -110,7 +110,7 @@ of the string and then selects everything after the new position. The following
example will save the numbers 1234 to the 'number' variable, still assuming
example will save the numbers 1234 to the 'number' variable, still assuming
we've dialed 918005551234.
we've dialed 918005551234.
\begin { verbatim}
\begin { verbatim}
; Remove everything before the last four digits of the dialed string
; Remove everything before the last four digits of the dialed string
exten => _ 9X.,1,Set(number=$ { EXTEN: - 4 } )
exten => _ 9X.,1,Set(number=$ { EXTEN: - 4 } )
\end { verbatim}
\end { verbatim}
We can also limit the number of characters from our offset position that we
We can also limit the number of characters from our offset position that we
@ -118,7 +118,7 @@ wish to use. This is done by appending a second colon and length value to the
variable name. The following example will save the numbers 555 to the 'number'
variable name. The following example will save the numbers 555 to the 'number'
variable.
variable.
\begin { verbatim}
\begin { verbatim}
; Only save the middle numbers 555 from the string 918005551234
; Only save the middle numbers 555 from the string 918005551234
exten => _ 9X.,1,Set(number=$ { EXTEN: 5 : 3 } )
exten => _ 9X.,1,Set(number=$ { EXTEN: 5 : 3 } )
\end { verbatim}
\end { verbatim}
The length value can also be used in conjunction with a negative offset. This
The length value can also be used in conjunction with a negative offset. This
@ -127,13 +127,13 @@ are. The following example will save the numbers 555 to the 'number' variable,
even if the string starts with more characters than expected (unlike the
even if the string starts with more characters than expected (unlike the
previous example).
previous example).
\begin { verbatim}
\begin { verbatim}
; Save the numbers 555 to the 'number' variable
; Save the numbers 555 to the 'number' variable
exten => _ 9X.,1,Set(number=$ { EXTEN: - 7 : 3 } )
exten => _ 9X.,1,Set(number=$ { EXTEN: - 7 : 3 } )
\end { verbatim}
\end { verbatim}
If a negative length value is entered, Asterisk will remove that many characters
If a negative length value is entered, Asterisk will remove that many characters
from the end of the string.
from the end of the string.
\begin { verbatim}
\begin { verbatim}
; Set pin to everything but the trailing #.
; Set pin to everything but the trailing #.
exten => _ XXXX#,1,Set(pin=$ { EXTEN: 0 : - 1 } )
exten => _ XXXX#,1,Set(pin=$ { EXTEN: 0 : - 1 } )
\end { verbatim}
\end { verbatim}
@ -274,7 +274,7 @@ Parentheses are used for grouping in the usual manner.
Operator precedence is applied as one would expect in any of the C
Operator precedence is applied as one would expect in any of the C
or C derived languages.
or C derived languages.
subsection{ Floating Point Numbers}
\ subsection{ Floating Point Numbers}
In 1.6 and above, we shifted the \$ \[ ... \] expressions to be calculated
In 1.6 and above, we shifted the \$ \[ ... \] expressions to be calculated
via floating point numbers instead of integers. We use 'long double' numbers
via floating point numbers instead of integers. We use 'long double' numbers
@ -290,13 +290,13 @@ on integer behavior. If you were counting on 1/4 evaluating to 0, you need to no
TRUNC(1/4). For a list of all the truncation/rounding capabilities, see the next section.
TRUNC(1/4). For a list of all the truncation/rounding capabilities, see the next section.
subsection{ Functions}
\ subsection{ Functions}
In 1.6 and above, we upgraded the $ [ ] expressions to handle floating point numbers.
In 1.6 and above, we upgraded the \$ [] expressions to handle floating point numbers.
Because of this, folks counting on integer behavior would be disrupted. To make
Because of this, folks counting on integer behavior would be disrupted. To make
the same results possible, some rounding and integer truncation functions have been
the same results possible, some rounding and integer truncation functions have been
added to the core of the Expr2 parser. Indeed, dialplan functions can be called from
added to the core of the Expr2 parser. Indeed, dialplan functions can be called from
$ [ .. ] expressions without the $ { ... } operators. The only trouble might be in the fact that
\$ [..] expressions without the \$ \{ ...\ } operators. The only trouble might be in the fact that
the arguments to these functions must be specified with a comma. If you try to call
the arguments to these functions must be specified with a comma. If you try to call
the MATH function, for example, and try to say 3 + MATH(7*8), the expression parser will
the MATH function, for example, and try to say 3 + MATH(7*8), the expression parser will
evaluate 7*8 for you into 56, and the MATH function will most likely complain that its
evaluate 7*8 for you into 56, and the MATH function will most likely complain that its
@ -312,7 +312,7 @@ are available by simply calling them (read-only). In other words, you don't need
surround function calls in \$ \[ ... \] expressions with \$ \{ ...\} . Don't jump to conclusions,
surround function calls in \$ \[ ... \] expressions with \$ \{ ...\} . Don't jump to conclusions,
though! -- you still need to wrap variable names in curly braces!
though! -- you still need to wrap variable names in curly braces!
\begin { E numerate}
\begin { e numerate}
\item COS(x) x is in radians. Results vary from -1 to 1.
\item COS(x) x is in radians. Results vary from -1 to 1.
\item SIN(x) x is in radians. Results vary from -1 to 1.
\item SIN(x) x is in radians. Results vary from -1 to 1.
\item TAN(x) x is in radians.
\item TAN(x) x is in radians.
@ -334,9 +334,9 @@ If this quotient is 1/2, it is rounded to the nearest even number.
\item LOG(x) returns the natural logarithm of x.
\item LOG(x) returns the natural logarithm of x.
\item LOG2(x) returns the base 2 log of x.
\item LOG2(x) returns the base 2 log of x.
\item LOG10(x) returns the base 10 log of x.
\item LOG10(x) returns the base 10 log of x.
\end { E numerate}
\end { e numerate}
subsection{ Examples}
\ subsection{ Examples}
\begin { verbatim}
\begin { verbatim}
"One Thousand Five Hundred" =~ "(T[^ ]+)"
"One Thousand Five Hundred" =~ "(T[^ ]+)"
@ -421,7 +421,7 @@ TRUNC(3.5)
TRUNC(-3.5)
TRUNC(-3.5)
returns -3.
returns -3.
\ b egi n{ verbatim}
\ end { verbatim}
Of course, all of the above examples use constants, but would work the
Of course, all of the above examples use constants, but would work the
same if any of the numeric or string constants were replaced with a
same if any of the numeric or string constants were replaced with a
@ -441,7 +441,7 @@ case.
There is one conditional application - the conditional goto :
There is one conditional application - the conditional goto :
\begin { verbatim}
\begin { verbatim}
exten => 1,2,gotoi f(condition?label1:label2)
exten => 1,2,GotoI f(condition?label1:label2)
\end { verbatim}
\end { verbatim}
If condition is true go to label1, else go to label2. Labels are interpreted
If condition is true go to label1, else go to label2. Labels are interpreted
@ -453,7 +453,7 @@ This is designed to be used together with the expression syntax described
above, eg :
above, eg :
\begin { verbatim}
\begin { verbatim}
exten => 1,2,gotoi f($ [ $ { CALLERID} = 123456]?2|1:3|1)
exten => 1,2,GotoI f($ [ $ { CALLERID} = 123456]?2|1:3|1)
\end { verbatim}
\end { verbatim}
Example of use :
Example of use :
@ -574,7 +574,7 @@ of possible concern with "legacy" extension.conf files:
quotes, it was no reason for concern. It is now!
quotes, it was no reason for concern. It is now!
\item LE, GE, NE operators removed. The code supported these operators,
\item LE, GE, NE operators removed. The code supported these operators,
but they were not documented. The symbolic operators, <=, >=, and !=
but they were not documented. The symbolic operators, $ <$ =, $ >$ =, and !=
should be used instead.
should be used instead.
\item Added the unary '-' operator. So you can 3+ -4 and get -1.
\item Added the unary '-' operator. So you can 3+ -4 and get -1.
@ -670,22 +670,24 @@ only read in the dialplan. Writes to such variables are silently
ignored.
ignored.
\begin { verbatim}
\begin { verbatim}
$ { ACCOUNTCODE} * Account code ( if specified ) ( Deprecated; use $ { CDR(accountcode)} )
$ { CDR( accountcode ) } * Account code ( if specified )
$ { BLINDTRANSFER } The name of the channel on the other side of a blind transfer
$ { BLINDTRANSFER } The name of the channel on the other side of a blind transfer
$ { BRIDGEPEER } Bridged peer
$ { BRIDGEPEER } Bridged peer
$ { CALLERANI } * Caller ANI ( PRI channels ) ( Deprecated; use $ { CALLERID(ani)} )
$ { CALLERID ( ani ) } * Caller ANI ( PRI channels )
$ { CALLERID } * Caller ID ( Deprecated; use $ { CALLERID(all)} )
$ { CALLERID ( all ) } * Caller ID
$ { CALLERIDNAME } * Caller ID Name only ( Deprecated; use $ { CALLERID(name)} )
$ { CALLERID ( dnid ) } * Dialed Number Identifier
$ { CALLERIDNUM } * Caller ID Number only ( Deprecated; use $ { CALLERID(num)} )
$ { CALLERID ( name ) } * Caller ID Name only
$ { CALLERID ( num ) } * Caller ID Number only
$ { CALLERID ( rdnis ) } * Redirected Dial Number ID Service
$ { CALLINGANI 2 } * Caller ANI 2 ( PRI channels )
$ { CALLINGANI 2 } * Caller ANI 2 ( PRI channels )
$ { CALLINGPRES } * Caller ID presentation for incoming calls ( PRI channels )
$ { CALLINGPRES } * Caller ID presentation for incoming calls ( PRI channels )
$ { CALLINGTNS } * Transit Network Selector ( PRI channels )
$ { CALLINGTNS } * Transit Network Selector ( PRI channels )
$ { CALLINGTON } * Caller Type of Number ( PRI channels )
$ { CALLINGTON } * Caller Type of Number ( PRI channels )
$ { CHANNEL } * Current channel name
$ { CHANNEL } * Current channel name
$ { CONTEXT } * Current context
$ { CONTEXT } * Current context
$ { DATETIME } * Current date time in the format: DDMMYYYY - HH:MM:SS ( Deprecated; use $ { STRFTIME($ { EPOCH } ,, % d % m % Y - % H: % M: % S ) } )
$ { DATETIME } * Current date time in the format: DDMMYYYY - HH:MM:SS
(Deprecated; use $ { STRFTIME ( $ { EPOCH} ,,% d% m% Y-% H:% M:% S)} )
$ { DB _ RESULT } Result value of DB _ EXISTS ( ) dial plan function
$ { DB _ RESULT } Result value of DB _ EXISTS ( ) dial plan function
$ { DNID } * Dialed Number Identifier ( Deprecated; use $ { CALLERID(dnid)} )
$ { EPOCH } * Current unix style epoch
$ { EPOCH } * Current unix style epoch
$ { EXTEN } * Current extension
$ { EXTEN } * Current extension
$ { ENV ( VAR ) } Environmental variable VAR
$ { ENV ( VAR ) } Environmental variable VAR
@ -701,8 +703,8 @@ ${LANGUAGE} * Current language (Deprecated; use ${LANGUAGE()})
$ { LEN ( VAR ) } * String length of VAR ( integer )
$ { LEN ( VAR ) } * String length of VAR ( integer )
$ { PRIORITY } * Current priority in the dialplan
$ { PRIORITY } * Current priority in the dialplan
$ { PRIREDIRECTREASON } Reason for redirect on PRI, if a call was directed
$ { PRIREDIRECTREASON } Reason for redirect on PRI, if a call was directed
$ { RDNIS} * Redirected Dial Number ID Service ( Deprecated; use $ { CALLERID(rdnis)} )
$ { TIMESTAMP} * Current date time in the format: YYYYMMDD - HHMMSS
$ { TIMESTAMP } * Current date time in the format: YYYYMMDD - HHMMSS ( Deprecated; use $ { STRFTIME($ { EPOCH } ,, % Y % m % d - % H % M % S ) } )
(Deprecated; use $ { STRFTIME ( $ { EPOCH} ,,% Y% m% d-% H% M% S)} )
$ { TRANSFER _ CONTEXT } Context for transferred calls
$ { TRANSFER _ CONTEXT } Context for transferred calls
$ { FORWARD _ CONTEXT } Context for forwarded calls
$ { FORWARD _ CONTEXT } Context for forwarded calls
$ { UNIQUEID } * Current call unique identifier
$ { UNIQUEID } * Current call unique identifier
@ -865,7 +867,7 @@ ${LIMIT_WARNING_FILE} Soundfile for call limits
$ { LIMIT _ TIMEOUT _ FILE } Soundfile for call limits
$ { LIMIT _ TIMEOUT _ FILE } Soundfile for call limits
$ { LIMIT _ CONNECT _ FILE } Soundfile for call limits
$ { LIMIT _ CONNECT _ FILE } Soundfile for call limits
$ { OUTBOUND _ GROUP } Default groups for peer channels ( as in SetGroup )
$ { OUTBOUND _ GROUP } Default groups for peer channels ( as in SetGroup )
* See "show application dial" for more information
* See "show application dial" for more information
\end { verbatim}
\end { verbatim}
\subsection { The chanisavail() application}
\subsection { The chanisavail() application}