1 GENERAL ENCHANCEMENTS TO EXTENSION LOGIC :
5 exten => s,5,BackGround,blabla
7 The parameter (blabla) can be quoted ("blabla"). In this case, a
8 comma does not terminate the field.
10 Also, characters special to variable substitution, expression evaluation, etc
11 (see below), can be quoted. For example, to literally use a $ on the
12 string "$1231", quote it with a preceeding \. Special characters that must
13 be quoted to be used, are [ ] $ " \. (to write \ itself, use \\).
17 Parameter strings can include variables. Variable names are arbitrary strings.
18 They are stored in the respective channel structure.
20 To set a variable to a particular value, do :
22 ;exten => 1,2,SetVar,varname=value
24 You can substitute the value of a variable everywhere using ${variablename}.
25 For example, to stringwise append $lala to $blabla and store result in $koko,
28 ;exten => 1,2,SetVar,koko=${blabla}${lala}
30 There are also the following special variables:
33 ${CALLERIDNAME} Caller ID Name only
34 ${CALLERIDNUM} Caller ID Number only
35 ${EXTEN} Current extension
36 ${CONTEXT} Current context
37 ${PRIORITY} Current priority
38 ${CHANNEL} Current channel name
40 There are two reference modes - reference by value and reference by name.
41 To refer to a variable with its name (as an argument to a function that
42 requires a variable), just write the name. To refer to the variable's value,
43 enclose it inside ${}. For example, SetVar takes as the first argument
44 (before the =) a variable name, so:
46 ;exten => 1,2,SetVar,koko=lala
47 ;exten => 1,3,SetVar,${koko}=blabla
49 stores to the variable "koko" the value "lala" and to variable "lala" the
52 In fact, everything contained ${here} is just replaced with the value of
57 Everything contained inside a bracket pair prefixed by a $ (like $[this]) is
58 considered as an expression and it is evaluated. Evaluation works similar to
59 (but is done on a later stage than) variable substitution: the expression
60 (including the square brackets) is replaced by the result of the expression
61 evaluation. The arguments and operands of the expression MUST BE separated
62 with spaces (take care NOT to leave ANY spaces between opening and closing
63 square brackets and the first and last arguments).
65 For example, after the sequence:
67 exten => 1,1,SetVar,"lala=$[1 + 2]";
68 exten => 1,2,SetVar,"koko=$[2 * ${lala}]";
70 the value of variable koko is "6".
72 Operators are listed below in order of increasing precedence. Operators
73 with equal precedence are grouped within { } symbols.
76 Return the evaluation of expr1 if it is neither an empty string
77 nor zero; otherwise, returns the evaluation of expr2.
80 Return the evaluation of expr1 if neither expression evaluates to
81 an empty string or zero; otherwise, returns zero.
83 expr1 {=, >, >=, <, <=, !=} expr2
84 Return the results of integer comparison if both arguments are
85 integers; otherwise, returns the results of string comparison
86 using the locale-specific collation sequence. The result of each
87 comparison is 1 if the specified relation is true, or 0 if the
91 Return the results of addition or subtraction of integer-valued
95 Return the results of multiplication, integer division, or
96 remainder of integer-valued arguments.
99 The `:' operator matches expr1 against expr2, which must be a
100 regular expression. The regular expression is anchored to the
101 beginning of the string with an implicit `^'.
103 If the match succeeds and the pattern contains at least one regu-
104 lar expression subexpression `\(...\)', the string correspond-
105 ing to `\1' is returned; otherwise the matching operator
106 returns the number of characters matched. If the match fails and
107 the pattern contains a regular expression subexpression the null
108 string is returned; otherwise 0.
110 Parentheses are used for grouping in the usual manner.
112 The parser must be parsed with bison (bison is REQUIRED - yacc cannot
113 produce pure parsers, which are reentrant)
117 There is one conditional operator - the conditional goto :
119 ;exten => 1,2,gotoif,condition?label1:label2
121 If condition is true go to label1, else go to label2. Labels are interpreted
122 exactly as in the normal goto command.
124 "condition" is just a string. If the string is empty or "0", the condition
125 is considered to be false, if it's anything else, the condition is true.
126 This is designed to be used together with the expression syntax described
129 exten => 1,2,gotoif,$[${CALLERID} = 123456]?2|1:3|1
134 exten => s,2,SetVar,"vara=1"
135 exten => s,3,SetVar,"varb=$[${vara} + 2]"
136 exten => s,4,SetVar,"varc=$[${varb} * 2]"
137 exten => s,5,GotoIf,"$[${varc} = 6]?99|1:s|6";