m (Bot: Adding a template) |
m (bot: sort-key added to category) |
||
Line 57: | Line 57: | ||
{{mIRC command list}} | {{mIRC command list}} | ||
− | [[Category: | + | [[Category:mIRC commands|var command - mIRC]] |
Revision as of 19:33, 29 July 2014
Template:mIRC menu 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 Jun 1999
Note: Unless otherwise stated, this was the date of original functionality.
Further enhancements may have been made in later versions.