From WikiChip
Difference between revisions of "mirc/identifiers/$calc"
< mirc‎ | identifiers

(Created $calc identifier - mIRC)
 
m (Examples)
Line 40: Line 40:
 
   }
 
   }
 
}</source>
 
}</source>
 +
 +
The above '''$power''' alias can now be used like so:
 +
<source lang="mIRC">//echo -a $power(2,2)</source>
 +
 +
The result of the above command would be:
 +
<pre>4</pre>
  
 
== Compatability ==
 
== Compatability ==

Revision as of 23:10, 23 June 2014

$calc can be used to perform mathematical calculations from the mIRC command line, or from inside of a custom script.

Synopsis

$calc(operations)

The $calc adheres to mathematical standards set forth by the order of operations. Therefore, a combination of brackets and parentheses can be used in order to manipulate the order of operations. $calc can also be used to calculate variables in mIRC, as well as other customer identifiers that return numerical values.

Parameters

operationsThese are a specific set of mathematical operations for $calc to perform.

Operators

+Addition

-Subtraction

*Multiplication

/Division

^Exponent

%Modulus

Examples

Echo a simple addition calculation to the active window

//echo -a $calc(3 + 5)

Echo a manipulated order of operations calculation to the active window

//echo -a $calc(3 * 4 * (3 + 5)))

Echo the remainder of the calculation, by invoking the modulus operator, to the active window

//echo -a $calc(10 % 3)

Create a simple alias to take in two parameters, then raise the first to the power of the second, and return the value

alias power {
 
  ; Make sure both inputs are numbers
  if (($1 isnum) && ($2 isnum)) {
    return $calc($1 ^ $2)
  }
}

The above $power alias can now be used like so:

//echo -a $power(2,2)

The result of the above command would be:

4

Compatability

Added: mIRC v5.1

Added On: 28/08/97

See Also