Project

General

Profile

Var » History » Version 20

Per Amundsen, 11/03/2020 06:19 AM

1 1 Per Amundsen
_Added in 1.8.8_
2
3 16 Per Amundsen
*/var [-gnspB] <%var> [[= ]value]*
4 1 Per Amundsen
5
Sets the value of local variable %var to the specified value.
6
7 6 Per Amundsen
Syntax can be either _var %var = value_ or _var %var value_.
8 5 Per Amundsen
9 9 Per Amundsen
Multiple variables can be set in one line using comma as separator, _var %var1 = value, %var2 = value2_.
10 5 Per Amundsen
11 19 Per Amundsen
_See also [[/set]], [[/unset]], [[/inc]], [[/dec]], [[$var]]._
12 14 Per Amundsen
13 1 Per Amundsen
*Switches*
14
15
-s - Display variable assignment value.
16
-g - Creates a global variable instead.
17
-n - Treat the value as plain text, even if arithmetic operators are used.
18 13 Per Amundsen
-i - Initializes a variable only if it does not already exist as a local or global variable.
19 1 Per Amundsen
-p - Permits value to be 2 literal double quotes and permits value to end with a single [[$chr]](32) space. Also enables -n switch behavior.
20 17 Per Amundsen
-B - Performs a [[$calcint]] calculation instead of regular [[$calc]] when arithmetic operators are used. *(AdiIRC only)*
21 1 Per Amundsen
22
*Parameters*
23
24
<%var> - The variable to set.
25 20 Per Amundsen
[ [= ]value ] - Value to set the variable to. (can be a single [[Arithmetic Operators|arithmetic expression]])
26 1 Per Amundsen
27
*Example*
28
29 2 Per Amundsen
<pre>
30 3 Per Amundsen
alias factorial {
31 1 Per Amundsen
  var %result = 1, %x = $1
32
  while (%x) {
33
    var %result = %result * $v1
34
    dec %x
35
  }
36
  return %result
37
}
38 3 Per Amundsen
39
;Returns 3628800
40
//echo -ag $factorial(10)
41 2 Per Amundsen
</pre>