mIRC Scripting

mIRC: Operators

Comparison Operators:

Comparison operators are used to compare two values in an /if statement.

Operator Description Example (all $TRUE)
== equal to if (2 == 2) {
=== case-sensitive equal to if (tEsT === tEsT) {
!= not equal to if (2 != 3) {
< less than if (2 < 5) {
> greater than if (9 > 2) {
>= greater than or equal to if (8 >= 5) {
<= less than or equal to if (5 <= 5) {
// is a multiple of if (3 // 6) {
\\ is not a multiple of if (2 \\ 3) {
& bitwise comparison if (7 & 1) {

 

Strings

isin / isincs

String v1 is in string v2. isincs is the case sensitive version of isin.

if (v1 isin v2) {
if (v1 isincs v2) {

Example:

if (h isin hello) {
if (there isin Hi there!) {

 

iswm / iswmcs

Wild string v1 matches string v2. Iswmcs is the case sensitive version of iswm.

* - any character zero or more times
? - any single character

if (v1 iswm v2) {
if (v1 iswmcs v2) {

Example:

if (*! iswm Hello!) {
if (H?llo iswm Hello) {

 

isnum

Number v1 is a number in the range n2. n2 can be a single number, from n2 and up (n2-), or a range of numbers n1-n2.

if (v1 isnum) {
if (v1 isnum n1) {
if (
v1 isnum n1-) {
if (v1 isnum n1-v2) {

Example:

if (55 isnum) {
if (10 isnum 10) {
if (
102 isnum 10-) {
if (3 isnum 1-99) {

 

isletter

Number v1 is a letter. v2 can be a list of letters. This operator IS case sensitive. This operator only checks the first letter of a string.

if (v1 isletter) {
if (v1 isletter v2) {

Example:

if (A isletter) {
if (c isletter abcABC) {
if (aGGGG isletter a) {

 

isalpha

V1 is made up of only letters.

if (v1 isalpha) {

Example:

if (hello isalpha) {

 

isalnum

V1 is made up of only letters and numbers.

if (v1 isalnum) {

Example:

if (h3llo isalnum) {

 

islower

V1 is made up of only lower case letters.

if (v1 islower) {

Example:

if (hi islower) {

 

isupper

V1 is made up of only upper case letters.

if (v1 isupper) {

Example:

if (HI isupper) {

 

IRC Related Operators:

ison

Nick ison Channel #Chan.

if (nick ison #chan) {

Example:

if (Tim ison #help) {

 

isreg

Nick is a regular user on #Chan.

if (nick isreg #chan) {

Example:

if (Jane isreg #bar) {

isvoice

Nick is a voice in #Chan .

if (nick isvoice #chan) {

Example:

if ($nick isvoice $chan) {
if (foo isvoice #bar) {

 

ishop

Nick is help-operator in #Chan.

if (nick ishop #chan) {

Example:

if ($nick ishop $chan) {
if (Dave03 ishop #Help) {

 

isop

Nick is an operator in #Chan.

if (nick isop #chan) {

Example:

if ($nick isop $chan) {
if (Mike isop #mIRC) {

 

ischan

#Chan is a channel which you are on

if (#chan ischan) {

Example:

if (#MyCahn ischan) {

 

Arithmetic Operators:

Operator Description Example Return
+ Subtraction $calc(3 + 3) 6
- Subtraction $calc(11 - 3) 8
/ Division $calc(21 / 7) 3
* Multiplication $calc(5 * 5) 25
% Modulus $calc(11 % 3) 2
^ Exponents $calc(5 ^ 2) 25

Please Note:
Spaces in the $calc are not needed, 1+1 will be the same as 1 + 1. The calc identifier supports multiple parentheses to change order of operations, For example: $calc( (2 + 2) * 2 ) = 8 and $calc( 2 + 2 * 2 ) = 6. When using variables, operators can be placed without a space before the % sign. For example: $calc(1-%a +%b).

One operator arithmetic problem can be set to a variable without the calc identifier:

Alias Math {
  var %add 2 + 2
  var %add %add + 2
  return %add
  ; 6
}

Assignment Operators:

mIRC offers just one way to set a variable (other than commands) using the equals sign (“=”).

%var = value

Logical Operators:

Logical operators are used to compare multiple conditions together.

Operator Description
|| OR
&& AND

 

Alias Test {
 if (2 < 4) && (6 > 2) echo -a Yes 2 > 4 AND 6 > 2!
 if (2 < 4) || (6 > 222222) echo -a 2 < 4, But I Don't Think 6 is more then 222222!
}