(→Channel-related Operators) |
(→Channel-related Operators) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 185: | Line 185: | ||
|- | |- | ||
|%x isop %y || Is an Operator || True, if nick %x is an operators on channel %y. | |%x isop %y || Is an Operator || True, if nick %x is an operators on channel %y. | ||
+ | |- | ||
+ | |%x isowner %y || Is an Owner || True, if nick %x is an owner on channel %y. | ||
|- | |- | ||
|%x ishop %y || Is a Halfop || True, if nick %x is a halfop on channel %y. | |%x ishop %y || Is a Halfop || True, if nick %x is a halfop on channel %y. | ||
Line 199: | Line 201: | ||
|} | |} | ||
− | '''Note''' the operator ishelp is the same as the operator ishop | + | '''Note''': the operator ishelp is the same as the operator ishop, and the operator isvo is the same as the operator isvoice |
Example: | Example: |
Latest revision as of 15:06, 19 July 2020
- If Then Else
- Operators
- While Loops
- Goto Loops
- Groups
By now, you should have a pretty good idea of what variables are and how to use them. Now, all you need to be able to do is operate on them. That's exactly what mIRC Operators lets you do. Operators are special symbols or keywords that perform specific operations on two or three operands in mIRC.
Contents
Operators[edit]
mIRC provides the following types of operators:
- Arithmetic Operators
- Math Comparison Operators
- String Comparison Operators
- Lexicographical String Comparison Operators
- Logical Operators
- Channel-related Operators
- List-related Operators
Arithmetic Operators[edit]
mIRC supports the following arithmetic operators:
Operator | Syntax |
---|---|
Addition | a + b |
Subtraction | a - b |
Multiplication | a * b |
Division | a / b |
Modulo | a % b |
Power | a ^ b |
Bitwise AND | a & b |
Floor division (does not work with /set and /var) | a // b |
They can be used in conjunction with the /var or /set commands as well as using the $calc Identifier. One special feature of the $calc identifier over the /var and /set commands is that it supports combination of operators as well as parenthesis to be able to change the order of operations.
alias example { var %x = 5 ;5 * 5 = 25 %x = %x * 5 echo -a %x ;remainder of 25 / 9 = 7 var %y = %x % 9 echo -a %y ;25 + 7 - 2 = 30 %x = $calc(%x + %y - 2) echo -a %x }
Math Comparison Operators[edit]
Math Comparison operators allow you to compare two values:
Syntax | Name | Result |
---|---|---|
%x == %y | Equal | True, if %x is equal to %y. |
%x != %y | Not equal | True, if %x is not equal to %y. |
%x < %y | Less than | True, if %x is strictly less than %y. |
%x > %y | Greater than | True, if %x is strictly greater than %y. |
%x <= %y | Less than or equal to | True, if %x is less than or equal to %y. |
%x >= %y | Greater than or equal to | True, if %x is greater than or equal to %y. |
%x // %y | Multiple Of (Divides) | True, if %x divides %y. |
%x \\ %y | Not Multiple Of (Not Divides) | True, if %x does not divides %y. |
%x & %y | Bitwise And | True, if (bit representation of) %x AND %y is a none zero. |
Example:
alias example2 { ;true (3 a multiple of 9) if (3 // 9) echo yes! ;false if (4 < 4) echo no ;00001010 = 10 ;00000100 = 4 ;00000000 = 0 ;true, we used the '!' to negate the operator if (10 !& 4) echo yes }
String Comparison Operators[edit]
mIRC provides a set of operators that can be used to compare two strings. The two iswm and iswmcs operators support two wildcard characters as well, the question mark (?) substitutes for any one character and the asterisk character ("*") substitutes for any zero or more characters.
Syntax | Name | Result |
---|---|---|
%x isin %y | Is In | True, if %x is fully found inside %y. |
%x isincs %y | Is In (case sensitive) | True, if %x is fully found inside (case sensitive) %y. |
%x iswm %y | Wildcard Matching | True, if wildcard string %x matches %y. |
%x iswmcs %y | Wildcard Matching (case sensitive) | True, if wildcard string %x matches (case sensitive) %y. |
%x isnum %x isnum N %x isnum N- %x isnum N-M |
Is Digit Is Digit, Equal to Is Digit, Greater than or equal to Is Digit, in Range |
True, if %x is a number True, if %x is number N True, if %x is number N or greater True, if %x is a number between N and M (inclusively) |
%x isletter %x isletter N |
Is a Letter Is a Letter In A List |
True, if %x is a letter True, if %x is a letter in a list of letters |
%x isalnum | Alphanumeric Characters | True, if %x contains only alphabetic or numeric characters. |
%x isalpha | Alphabetic Characters | True, if %x contains only alphabetic characters. |
%x islower | All lower case letters | True, if %x does not contain any upper case letters. %x can contain non alphabetic characters. |
%x isupper | All upper case letters | True, if %x does not contain any lower case letters. %x can contain non alphabetic characters. |
Example:
alias example3 { var %x = Hello! if (?ell?? iswm %x) echo true ;false, because of '!' if (%x isalpha) echo no %x = 5 if (%x isnum 1-10) echo true if (%x isnum) echo true }
Lexicographical String Comparison Operators[edit]
A lexicographical comparison is a comparison generally used to sort words alphabetically in dictionaries and indexes. If both strings are equal but one is shorter than the other, the shorter string is lexicographically less than the longer one.
Syntax | Name | Result |
---|---|---|
a == b | Case insensitive character comparison | True, if character a is equal to character b, case insensitive. |
a === b | Case sensitive character comparison | True, if character a is equal to character b, case sensitive. |
a != b a !== b |
Case insensitive character comparison | True, if character a is not equal to character b, case insensitive. |
a !=== b | Case sensitive character comparison | True, if character a is not equal to character b, case sensitive. |
str1 == str2 | Case insensitive String comparison | True, if str1 equals str2 in a case insensitive manner. |
str1 === str2 | Case sensitive String comparison | True, if str1 equals str2 in a case sensitive manner. |
str1 != str2 str1 !== str2 |
Case insensitive String comparison | True, if str1 does not equal str2 in a case insensitive manner. |
str1 !=== str2 | Case sensitive String comparison | True, if str1 does not equal str2 in a case sensitive manner. |
a < b | Lexicographically Less Than | True, if the $asc(a) comes before $asc(b) |
a > b | Lexicographically Greater Than | True, if the $asc(a) comes after $asc(b) |
str1 < str2 | Lexicographically Less Than | True, if str1 comes before str2 |
str1 > str2 | Lexicographically Greater Than | True, if str1 comes after str2 |
Logical Operators[edit]
In an if statement, you are allowed to have more than one condition. Each condition has to be connected to the other using a logical operator. There are two logical operators: || meaning OR and && meaning AND.
Example:
if ((%x < 0) || (%x > 10)) {
In the if statement above, %x has to be less than 0 OR greater than 10 to make the if statement be true.
if ((%input isupper) && ($len(%input) < 10)) {
The if statement above will only be true if %a contains only upper case letters and its total length is less than 10.
Short-circuit evaluation[edit]
mIRC will only evaluate as much of the condition has it needs. Consider the AND example from above, if %input doesn't contain only upper case letters, the second condition will never even evaluate. This is important to keep in mind when using custom identifiers inside an if statement.
[edit]
mIRC also provides a set of commands to involve IRC channels:
Syntax | Name | Result |
---|---|---|
%x ison %y | Is On | True, if nick %x is on channel %y. |
%x isop %y | Is an Operator | True, if nick %x is an operators on channel %y. |
%x isowner %y | Is an Owner | True, if nick %x is an owner on channel %y. |
%x ishop %y | Is a Halfop | True, if nick %x is a halfop on channel %y. |
%x isvoice %y | Is a Voice | True, if nick %x is a voice on channel %y (isvo operator also supported). |
%x isreg %y | Is a Regular | True, if nick %x is a regular user on channel %y. |
%x ischan | Is a Channel | True, if channel %x is a channel you are on and if the %x channel window is still open (doesn't matter if you are connected or not). |
%x isban %y | Is a ban | True, if ban address %x is a ban on channel %y. (taken from IBL) |
%x isquiet %y | Is a quiet ban | True, if ban address %x is a quiet ban on channel %y. (taken from IQL) |
Note: the operator ishelp is the same as the operator ishop, and the operator isvo is the same as the operator isvoice
Example:
alias example4 { ;am I on #mIRC if (#mIRC ischan) echo yes ;is that ban on #mSL's internal ban list? if (*!*@example.com isban #offTopic) echo yes ;am I an OP on #mIRC? if ($me isop #mIRC) echo yes }
[edit]
mIRC has 5 additional operators to check mIRC internal lists:
Syntax | Name | Result |
---|---|---|
%x isaop %x isaop %y |
In Auto-Op List In Auto-Op List For Chan |
True, if host %x is in the auto-op list. True, if host %x is in the auto-op list for channel %y. |
%x isavoice %x isavoice %y |
In Auto-Voice List In Auto-Voice List For Chan |
True, if host %x is in the auto-voice list. True, if host %x is in the auto-voice list for channel %y. |
%x isignore %x isignore %y |
In Ignore List In Ignore List For Type |
True, if host %x is in the ignore list. True, if host %x is in the ignore list for type %y. |
%x isprotect %x isprotect %y |
In Protect List In Protect List For Chan |
True, if host %x is in the protect list. True, if host %x is in the protect list for channel %y. |
%x isnotify | In Notify List | True, if host %x is in the notify list. |
Note: the operator isauto is the same as the operator isaop.
Example:
Alias example5 { ;is the host in the auto-op list if (dave101!*@* isaop) echo yes ;assume we have ignore all ctcps: /ignore -tw *!*@* ;check if *!*@* in the ignore list for CTCPs: if (*!*@* isignore ctcp) echo yes }