Set Command Question

I was reading and getting confused, in that it looked like the SET command may have at one point allowed you to set multiple variables with one command, but is that true? And if it is, what is the proper syntax? Thanks!

Try this:

Name
Set() — Sets a variable to the specified value

Synopsis
Set(n=value,[n2=value2…[,options]])
Sets the variable n to the specified value. Also sets the variable n2 to the value of value2. If the variable name is prefixed with _, single inheritance is assumed. If the variable name is prefixed with _ _, infinite inheritance is assumed. Inheritance is used when you want channels created from the current channel to inherit the variable from the current channel.

If the options parameter is set to g, the variables will be set as global variables instead of channel variables.

1 Like

Thanks! So in my example:

Set(var1=2020,[var2=2121,[var3=2222)

Do I need to close the opening brackets for var 2 & 3?

You may be thinking of the mset() application.

However, if an application’s description says ‘Avoid its use if possible.’ maybe you should.

The brackets are only used in the description to identify anything inside them as optional.
When actually using the application you should omit the brackets.

Assuming you are referring to the ARRAY function

https://wiki.asterisk.org/wiki/display/AST/Asterisk+18+Function_ARRAY

same => n,Set(ARRAY(var1,var2)=1,2)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.