(Created page with "The '''/var command''' can be used to replace the value of existing variables or create a new variables and assign them values. By default /var creates local variable, this ca...") |
(→Switches) |
||
Line 23: | Line 23: | ||
* '''-s''' - Display variable assignment value | * '''-s''' - Display variable assignment value | ||
* '''-g''' - Creates a global variable instead | * '''-g''' - Creates a global variable instead | ||
+ | * '''-n''' - Treats value as plain text | ||
== Parameters == | == Parameters == |
Revision as of 18:06, 27 May 2014
The /var command can be used to replace the value of existing variables or create a new variables and assign them values. By default /var creates local variable, this can be changed via the -g switch (/set command can be used to set global variables by default).
The var command can perform one math operation via one of the arithmetic operators: addition (+), subtraction (-), multiplication (*), division (/), and modulo (%). They must be space delimited with both operands being a number. If any of the operands are not a number or if a space is missing, it will be treated as plain text.
Note: Unlike the /set command, var can assign a value to multiple variables at once.
Set Evaluation Routine: Internally, the var command simply breaks down the line (by commas) and passes the arguments to /set. The set command has its own evaluation routine which lets you dynamically concatenate additional values onto the variable name before the assignment takes place.
//var -ls % $+ $ctime ABC
Will create a variable like %1209425041 with the value of 'ABC'; Similarly this can be used with $nick and $chan in on events.
Synopsis
/var [-sg] <%var> [[= ]value] /var [-sg] <%var> <number> <+ | - | * | / | %> <number> /var [-sg] <%var> [= ]<number> <+ | - | * | / | %> <number> /var [-sg] <%var> [[= ]value][, <%var> [[= ]value]][, ...] /var [-sg] <%var> [= ]<number> <+ | - | * | / | %> <number>[, ...]
Switches
- -s - Display variable assignment value
- -g - Creates a global variable instead
- -n - Treats value as plain text
Parameters
- <%var> - The name of the variable
- [value] - The value to assign to the variable
- <number> - Any arbitrary numerical value, can be a floating point number
- <+ | - | * | / | %> - One of the five possible arithmetic operations
- <number> - Any arbitrary numerical value, can be a floating point number
Example
; Factorial ; 10! = $factorial(10) = 3628800 alias factorial { var %result = 1, %x = $1 while (%x) { var %result = %result * $v1 dec %x } return %result }
Compatibility
Added: mIRC v5.6
Added On: 03/06/99
Note: Individual switches were not taken into consideration.