/var
Indice
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.
| Contents - 1 Synopsis - 2 Switches - 3 Parameters - 4 Example - 5 Compatibility - 6 See also |
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
- Any arbitrary numerical value, can be a floating point number - <+ | - | * | / | %> - One of the five possible arithmetic operations
- 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: 06/03/1999
Note: Individual switches were not taken into consideration.
See also
mIRC commands list