From WikiChip
Difference between revisions of "mirc/commands/inc"
< mirc‎ | commands

m (Bot: de-linking old mIRC menu)
m (add detail & examples)
Line 1: Line 1:
 
{{mirc title|/inc Command}}
 
{{mirc title|/inc Command}}
The '''/inc command''' increases the value of a variable by a given value. If no value is specified, mIRC will increase the variable by one. The /inc command works with both positive and negative values alike.
+
The '''/inc command''' increases the numeric value of a variable by a given value. If [value] is not specified, mIRC will increase the variable by one. The /inc command works with both positive and negative values alike.
  
 
== Synopsis ==
 
== Synopsis ==
Line 6: Line 6:
  
 
== Switches ==
 
== Switches ==
* '''-c''' - Increases the variable once per second  
+
* '''-c''' - Increases the variable by 1 every second  
 
* '''-s''' - Prints out the value of the variable  
 
* '''-s''' - Prints out the value of the variable  
* '''-z''' - Decreases the variable every second until it reaches zero at which point the variable will get removed.  
+
* '''-z''' - Decreases the variable by 1 every second until it reaches zero at which point the variable will get removed.  
 
* '''-e''' - Unsets the variable when mIRC exits  
 
* '''-e''' - Unsets the variable when mIRC exits  
 
* '''-uN''' - Increases the variable once and unsets the variable after N seconds
 
* '''-uN''' - Increases the variable once and unsets the variable after N seconds
 
* '''-k''' - Keeps the unset time of the variable if it exists. Watch out, currently -k in /inc does not behave the same as in {{mIRC|/set}}, as in, if you provide another -uN switch AND a -k switch, it will use this new unset time and won't preserve the original one.
 
* '''-k''' - Keeps the unset time of the variable if it exists. Watch out, currently -k in /inc does not behave the same as in {{mIRC|/set}}, as in, if you provide another -uN switch AND a -k switch, it will use this new unset time and won't preserve the original one.
 +
 +
Note: -c and -z and -uN do not observe the second changing while executing a script, so -c and -z switches have no effect on a local variable, and -uN will not decrement until after the script finishes.
  
 
== Parameters ==
 
== Parameters ==
 
* '''%var''' - The variable's name  
 
* '''%var''' - The variable's name  
* '''[value]''' - Optional numeric value to increase the variable by
+
* '''[value]''' - Optional numeric value to increase the variable by. Default is 1 if [value] not used or %variable / $identifier evaluates to $null
  
 
== Example ==
 
== Example ==
Line 27: Line 29:
 
}</syntaxhighlight>
 
}</syntaxhighlight>
  
 +
<source lang="mIRC">
 +
Note: if script or timer execution lasts longer than 1 second, -c and -z can skip increments or decrements:
 +
//set %i 10 | inc -z %i | timertest 5 1 echo -a $!timer(test).reps $!asctime i= $eval(%i,0) $(|) var $eval(%j,0) 99999 $(|) while ( $eval(%j,0) ) $chr(123) var $eval(%k,0) $!rand(1,999) $(|) dec $eval(%j,0) $chr(125) | echo -a com: $timer(test).com | timer
 +
 +
//var %i 1 | inc %i 0 | echo -a this did not change i= %i | var %j $null | inc %i | echo -a this changed by 1 because [value] is null i= %i
 +
  this did not change i= 1
 +
  this changed by 1 because [value] is null i= 2
 +
  this incremented by 3 i= 5
 +
 +
//var %i foo | inc %i | inc %i 5 | echo -a inc does not alter non-numeric values i= %i
 +
</source>
 
== Compatibility ==
 
== Compatibility ==
 
{{mIRC compatibility|4.0}}
 
{{mIRC compatibility|4.0}}
 
 
== See also ==
 
== See also ==
 
* [[List of commands - mIRC|List of commands]]
 
* [[List of commands - mIRC|List of commands]]
Line 40: Line 52:
 
* {{mIRC|/var}}
 
* {{mIRC|/var}}
 
{{mIRC command list}}
 
{{mIRC command list}}
 
 
[[Category:mIRC commands|inc command - mIRC]]
 
[[Category:mIRC commands|inc command - mIRC]]

Revision as of 14:37, 14 November 2017

The /inc command increases the numeric value of a variable by a given value. If [value] is not specified, mIRC will increase the variable by one. The /inc command works with both positive and negative values alike.

Synopsis

/inc [-sczeuNk] <%var> [value]

Switches

  • -c - Increases the variable by 1 every second
  • -s - Prints out the value of the variable
  • -z - Decreases the variable by 1 every second until it reaches zero at which point the variable will get removed.
  • -e - Unsets the variable when mIRC exits
  • -uN - Increases the variable once and unsets the variable after N seconds
  • -k - Keeps the unset time of the variable if it exists. Watch out, currently -k in /inc does not behave the same as in /set, as in, if you provide another -uN switch AND a -k switch, it will use this new unset time and won't preserve the original one.

Note: -c and -z and -uN do not observe the second changing while executing a script, so -c and -z switches have no effect on a local variable, and -uN will not decrement until after the script finishes.

Parameters

  • %var - The variable's name
  • [value] - Optional numeric value to increase the variable by. Default is 1 if [value] not used or %variable / $identifier evaluates to $null

Example

Alias Example {
  ;Create a local variable and set it to 5
  var %x 5
  ;Increase %x by 5 
  inc %x 5
  ;Print out %x's content
  echo -a %x
}
Note: if script or timer execution lasts longer than 1 second, -c and -z can skip increments or decrements:
//set %i 10 | inc -z %i | timertest 5 1 echo -a $!timer(test).reps $!asctime i= $eval(%i,0) $(|) var $eval(%j,0) 99999 $(|) while ( $eval(%j,0) ) $chr(123) var $eval(%k,0) $!rand(1,999) $(|) dec $eval(%j,0) $chr(125) | echo -a com: $timer(test).com | timer
 
//var %i 1 | inc %i 0 | echo -a this did not change i= %i | var %j $null | inc %i | echo -a this changed by 1 because [value] is null i= %i
  this did not change i= 1
  this changed by 1 because [value] is null i= 2
  this incremented by 3 i= 5
 
//var %i foo | inc %i | inc %i 5 | echo -a inc does not alter non-numeric values i= %i

Compatibility

Added: mIRC v4.0
Added on: 20 Mar 1996
Note: Unless otherwise stated, this was the date of original functionality.
Further enhancements may have been made in later versions.

See also

[Expand]
v · d · e mIRC commands list