@ -22,8 +22,8 @@ will be passed down to the Background command, in this example.
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 preceding \ \ . Special characters that must
be quoted to be used, are [ ] \$ " \ \. (to write \\ itself, use \\ ).
string "\$ 1231", quote it with a preceding \ textbackslash . Special characters that must
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
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.
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}
exten => 1,2,Set(varname=value)
\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
skip from the beginning of the string to the variable name.
\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 } )
\end { verbatim}
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
we've dialed 918005551234.
\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 } )
\end { verbatim}
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.
\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 } )
\end { verbatim}
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
previous example).
\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 } )
\end { verbatim}
If a negative length value is entered, Asterisk will remove that many characters
from the end of the string.
\begin { verbatim}
; Set pin to everything but the trailing #.
; Set pin to everything but the trailing #.
exten => _ XXXX#,1,Set(pin=$ { EXTEN: 0 : - 1 } )
\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
or C derived languages.
subsection{ Floating Point Numbers}
\ subsection{ Floating Point Numbers}
In 1.6 and above, we shifted the \$ \[ ... \] expressions to be calculated
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.
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
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
$ [ .. ] 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 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
@ -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,
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 SIN(x) x is in radians. Results vary from -1 to 1.
\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 LOG2(x) returns the base 2 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}
"One Thousand Five Hundred" =~ "(T[^ ]+)"
@ -421,7 +421,7 @@ TRUNC(3.5)
TRUNC(-3.5)
returns -3.
\ b egi n{ verbatim}
\ end { verbatim}
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
@ -441,7 +441,7 @@ case.
There is one conditional application - the conditional goto :
\begin { verbatim}
exten => 1,2,gotoi f(condition?label1:label2)
exten => 1,2,GotoI f(condition?label1:label2)
\end { verbatim}
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 :
\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}
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!
\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.
\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.
\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
$ { BRIDGEPEER } Bridged peer
$ { CALLERANI } * Caller ANI ( PRI channels ) ( Deprecated; use $ { CALLERID(ani)} )
$ { CALLERID } * Caller ID ( Deprecated; use $ { CALLERID(all)} )
$ { CALLERIDNAME } * Caller ID Name only ( Deprecated; use $ { CALLERID(name)} )
$ { CALLERIDNUM } * Caller ID Number only ( Deprecated; use $ { CALLERID(num)} )
$ { CALLERID ( ani ) } * Caller ANI ( PRI channels )
$ { CALLERID ( all ) } * Caller ID
$ { CALLERID ( dnid ) } * Dialed Number Identifier
$ { 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 )
$ { CALLINGPRES } * Caller ID presentation for incoming calls ( PRI channels )
$ { CALLINGTNS } * Transit Network Selector ( PRI channels )
$ { CALLINGTON } * Caller Type of Number ( PRI channels )
$ { CHANNEL } * Current channel name
$ { 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
$ { DNID } * Dialed Number Identifier ( Deprecated; use $ { CALLERID(dnid)} )
$ { EPOCH } * Current unix style epoch
$ { EXTEN } * Current extension
$ { ENV ( VAR ) } Environmental variable VAR
@ -701,8 +703,8 @@ ${LANGUAGE} * Current language (Deprecated; use ${LANGUAGE()})
$ { LEN ( VAR ) } * String length of VAR ( integer )
$ { PRIORITY } * Current priority in the dialplan
$ { 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 ( Deprecated; use $ { STRFTIME($ { EPOCH } ,, % Y % m % d - % H % M % S ) } )
$ { TIMESTAMP} * Current date time in the format: YYYYMMDD - HHMMSS
(Deprecated; use $ { STRFTIME ( $ { EPOCH} ,,% Y% m% d-% H% M% S)} )
$ { TRANSFER _ CONTEXT } Context for transferred calls
$ { FORWARD _ CONTEXT } Context for forwarded calls
$ { UNIQUEID } * Current call unique identifier
@ -865,7 +867,7 @@ ${LIMIT_WARNING_FILE} Soundfile for call limits
$ { LIMIT _ TIMEOUT _ FILE } Soundfile for call limits
$ { LIMIT _ CONNECT _ FILE } Soundfile for call limits
$ { 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}
\subsection { The chanisavail() application}