From WikiChip
Editing mirc/commands/var
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
This page supports semantic in-text annotations (e.g. "[[Is specified as::World Heritage Site]]") to build structured and queryable content provided by Semantic MediaWiki. For a comprehensive description on how to use annotations or the #ask parser function, please have a look at the getting started, in-text annotation, or inline queries help pages.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
− | |||
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 ({{mIRC|/set}} command can be used to set global variables by default). | 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 ({{mIRC|/set}} command can be used to set global variables by default). | ||
− | The | + | 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 {{mIRC|/set}} command, var can assign a value to multiple variables at once. | Note: Unlike the {{mIRC|/set}} command, var can assign a value to multiple variables at once. | ||
Line 11: | Line 9: | ||
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. | 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. | ||
− | <syntaxhighlight lang="mIRC">//var - | + | <syntaxhighlight lang="mIRC">//var -ls % $+ $ctime ABC</syntaxhighlight> |
Will create a variable like %1209425041 with the value of 'ABC'; Similarly this can be used with $nick and $chan in on events. | Will create a variable like %1209425041 with the value of 'ABC'; Similarly this can be used with $nick and $chan in on events. | ||
== Synopsis == | == Synopsis == | ||
− | /var [- | + | /var [-sg] <%var> [[= ]value] |
/var [-sg] <%var> <number> <+ | - | * | / | %> <number> | /var [-sg] <%var> <number> <+ | - | * | / | %> <number> | ||
− | /var [-sg] <%var> [= ]<number> <+ | - | * | / | % | + | /var [-sg] <%var> [= ]<number> <+ | - | * | / | %> <number> |
/var [-sg] <%var> [[= ]value][, <%var> [[= ]value]][, ...] | /var [-sg] <%var> [[= ]value][, <%var> [[= ]value]][, ...] | ||
− | /var [-sg] <%var> [= ]<number> <+ | - | * | / | % | + | /var [-sg] <%var> [= ]<number> <+ | - | * | / | %> <number>[, ...] |
== Switches == | == Switches == | ||
* '''-s''' - Display variable assignment value | * '''-s''' - Display variable assignment value | ||
* '''-g''' - Creates a global variable instead | * '''-g''' - Creates a global variable instead | ||
− | * '''-n''' - | + | * '''-n''' - Treats value as plain text |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== Parameters == | == Parameters == | ||
* '''<%var>''' - The name of the variable | * '''<%var>''' - The name of the variable | ||
− | * '''[value]''' - The value to assign to the variable | + | * '''[value]''' - The value to assign to the variable |
* '''<number>''' - Any arbitrary numerical value, can be a floating point number | * '''<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 | * '''<number>''' - Any arbitrary numerical value, can be a floating point number | ||
− | |||
− | |||
== Example == | == Example == | ||
Line 54: | Line 43: | ||
return %result | return %result | ||
}</syntaxhighlight> | }</syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== Compatibility == | == Compatibility == | ||
{{mIRC compatibility|5.6}} | {{mIRC compatibility|5.6}} | ||
+ | |||
== See also == | == See also == | ||
+ | * [[List of commands - mIRC|List of commands]] | ||
+ | * [[List of identifiers - mIRC|List of identifiers]] | ||
* {{mIRC|$var}} | * {{mIRC|$var}} | ||
* {{mIRC|/set}} | * {{mIRC|/set}} | ||
* {{mIRC|/unset}} | * {{mIRC|/unset}} | ||
* {{mIRC|/unsetall}} | * {{mIRC|/unsetall}} | ||
− | + | {{mIRC command list}} | |
+ | |||
+ | [[Category:MIRC commands]] |