B.110. Set()

Sets a variable to the specified value.
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 clearglobalvars in extensions.conf.
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' =- 

Set channel variable(s) or function value(s)

This function can be used to set the value of channel variables or dialplan
functions. It will accept up to 24 name/value pairs. When setting variables,
if the variable name is prefixed with _, the variable will be inherited into
channels created from the current channel. If the variable name is prefixed
with __, the variable will be inherited into channels created from the current
channel and all children channels.
    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
Section B.54, “ImportVar(), doc/README.variables (1.2) / doc/channelvariables.txt (1.4), Section C.21, “GLOBAL()