Var » History » Version 21
  Per Amundsen, 02/16/2023 05:07 PM 
  
| 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 | 21 | Per Amundsen | table(ktable). | 
| 16 | |*Switch*|*Description*| | ||
| 17 | | -s | Display variable assignment value. | | ||
| 18 | | -g | Creates a global variable instead. | | ||
| 19 | | -n | Treat the value as plain text, even if arithmetic operators are used. | | ||
| 20 | | -i | Initializes a variable only if it does not already exist as a local or global variable. | | ||
| 21 | | -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. | | ||
| 22 | | -B | Performs a [[$calcint]] calculation instead of regular [[$calc]] when arithmetic operators are used. *(AdiIRC only)* | | ||
| 23 | 1 | Per Amundsen | |
| 24 | 17 | Per Amundsen | *Parameters* | 
| 25 | 1 | Per Amundsen | |
| 26 | 21 | Per Amundsen | table(ktable). | 
| 27 | |*Parameter*|*Description*| | ||
| 28 | | <%var> | The variable to set. | | ||
| 29 | | [ [= ]value ] | Value to set the variable to. (can be a single [[Arithmetic Operators<notextile>|</notextile>arithmetic expression]]) | | ||
| 30 | 1 | Per Amundsen | |
| 31 | *Example* | ||
| 32 | |||
| 33 | 2 | Per Amundsen | <pre> | 
| 34 | 3 | Per Amundsen | alias factorial { | 
| 35 | 1 | Per Amundsen | var %result = 1, %x = $1 | 
| 36 |   while (%x) { | ||
| 37 | var %result = %result * $v1 | ||
| 38 | dec %x | ||
| 39 | } | ||
| 40 | return %result | ||
| 41 | } | ||
| 42 | 3 | Per Amundsen | |
| 43 | ;Returns 3628800 | ||
| 44 | //echo -ag $factorial(10) | ||
| 45 | 2 | Per Amundsen | </pre> |