m (Bot: Automated text replacement (-<small>Note: Individual switches were not taken into consideration.</small> +)) |
m (Bot: Automated text replacement (-Added On:.+\n?\n?\n?\n?\n? +)) |
||
Line 46: | Line 46: | ||
== Compatibility == | == Compatibility == | ||
Added: mIRC v5.6 | Added: mIRC v5.6 | ||
− | |||
− | |||
− | |||
− | |||
− | |||
== See also == | == See also == |
Revision as of 23:29, 5 July 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