Sets a variable to the specified value.
Set(variable=value[,variable2=value2,...][,options])
Sets the variable to the specified value. If the variable name
starts with "_", single inheritance is set
(i.e. the variable is inherited by any channels
opened from this channel); if it begins with "__", unlimited
inheritance is set (i.e. all children of this channel, regardless of
generation, inherit the variable). Up to 24 variables may be set.
Variables are valid only in the channel and are cancelled when the channel
is hung up. Option g sets a global variable in Asterisk 1.2;
in 1.4 this is accomplished with the Asterisk function
GLOBAL().
; Set a variable TEST to "123":
exten => 123,1,Set(TEST=123)
exten => 123,n,SayDigits(${TEST})
; Set a global variable TEST2 to "456":
exten => 123,n,Set(TEST2=456,g) ; Asterisk 1.2
exten => 123,n,Set(GLOBAL(TEST2)=456) ; Asterisk 1.4
|
|
|
Whether global variables are cleared upon
reload depends on the setting of
|
Set() is also used to write to
functions (see Appendix C, Functions in the dialplan).
exten => 123,1,Set(CALLERID(name)=Widgets) ; set CALLERID(name)
exten => 123,n,Set(CALLERID(name)=) ; clear CALLERID(name)
exten => 123,n,Set(DB(my/test)=ok) ; write a value to the AstDB
exten => 123,n,Set(var=${DB(my/test)}) ; read a value from the AstDB
|
|
|
Internal help for this application in Asterisk 1.4: -= Info about application 'Set' =-
[Synopsis]
Set channel variable(s) or function value(s)
[Description]
Set(name1=value1|name2=value2|..[|options])
This function can be used to set the value of channel variables or dialp
lan
functions. It will accept up to 24 name/value pairs. When setting variab
les,
if the variable name is prefixed with _, the variable will be inherited
into
channels created from the current channel. If the variable name is prefi
xed
with __, the variable will be inherited into channels created from the c
urrent
channel and all children channels.
Options:
g - Set variable globally instead of on the channel
(applies only to variables, not functions)
diff output to internal help in Asterisk 1.2: - none - |
See also. the section called “ImportVar()”,
doc/README.variables (1.2) /
doc/channelvariables.txt (1.4), the section called “GLOBAL()”