MIRC script
Encyclopedia
The mIRC scripting language, often unofficially abbreviated to 'mSL', is the scripting language embedded in mIRC
, a popular IRC client for Windows
.
Multiple script files can be loaded at one time, although in some cases, one script will conflict with another and cause one or both of them to no longer work properly.
The above is intended for singular access to the file. Because each time you issue
Multiple accesses, during a loop for instance, is best handled through
Here is an example of a Hello World alias:
Counting to 10:
A remote script event handler:
A remote script to automatically respond to certain text
Here is an example of picture windows:
MIRC
mIRC is an Internet Relay Chat client for Microsoft Windows, created in 1995 and developed by Khaled Mardam-Bey. Although it is a fully functional chat utility, its integrated scripting language makes it extensible and versatile....
, a popular IRC client for Windows
Microsoft Windows
Microsoft Windows is a series of operating systems produced by Microsoft.Microsoft introduced an operating environment named Windows on November 20, 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces . Microsoft Windows came to dominate the world's personal...
.
Primary uses
- Channel and personal protection against any types of attacks (flooding, spamming, CTCP floods, etc.).
- Dialog windows can be created in mIRC to better serve user-compatibility.
- Popular mIRC dialog extensions include MDX (mIRC Dialog Extension) and DCX (Dialog Control Extension). There are also a few versions of mdx.dll and dcx.dll modded by IRC hackers.
- BotIRC botthumb|409px|right|An IRC bot performing a simple task.An IRC bot is a set of scripts or an independent program that connects to Internet Relay Chat as a client, and so appears to other IRC users as another user...
s that provide automated IRC channel management, trivia or other games, and other desired functions for chatters. - Commands that save typing or otherwise simplify life on IRC (such as automatically identifyingIRC servicesInternet Relay Chat services is a name for a set of features implemented on many modern Internet Relay Chat networks. Services are automated bots with special status which are generally used to provide users with access with certain privileges and protection...
as the owner of a nickname).
Script storage
Scripts are stored as either plain text files, usually with a .mrc file extension, or as INI files. They however can be stored with any extension. It can be: .exe, .script, etc.Multiple script files can be loaded at one time, although in some cases, one script will conflict with another and cause one or both of them to no longer work properly.
Language features
mIRC scripting involves a peculiar nomenclature that is not entirely consistent with most of the rest of the programming world. (Most notably, the term identifier—which in most languages refers to the name of a variable or function (whether it returns a value or not)—in mIRC refers specifically to a value returning function.)- Built-in functions are termed commands or, if they return a value, identifiers.
- Custom scripted functions are called aliases. Aliases that return a value are known as custom identifiers. Both are called from the command line or other parts of a script in the same ways as built-in commands and identifiers (and can even supersede them).
- Popups are scripted context menuContext menuA context menu is a menu in a graphical user interface that appears upon user interaction, such as a right mouse click or middle click mouse operation...
items. Popups are called when they are selected by the user. The term originally referred to the menus—which pop up upon a right click. It is still used this way in the manual. But the user community (who tend not to read scripting manuals) took to calling the individual items popups—perhaps thinking of the colourful novelty actions that are popular with many users as pages of a popup book. - Remotes are event-handling scripts. Remotes are called when the event they handle occurs.
- All variables are dynamically typed.
- mIRC scripts make use of sigilsSigil (computer programming)In computer programming, a sigil is a symbol attached to a variable name, showing the variable's datatype or scope. In 1999 Philip Gwyn adopted the term "to mean the funny character at the front of a Perl variable".- Historical context:...
. Identifiers (whether custom or built-in) are preceded by$
, binary variables are preceded by&
, and other variables (whether local or global) are preceded by%
. Commands and aliases are not preceded by any particular character (although when entered from a window's command line they must be preceded by the command prefix, usually/
).
File handling
- Scripts can read from and write to files [
$read(file,[args])
|/write
]
The above is intended for singular access to the file. Because each time you issue
$read
or /write
you open and close the file for access.Multiple accesses, during a loop for instance, is best handled through
/fopen
, /fwrite
and /fclose
. Since this opens the file only once. In some cases /filter
and /savebuf
is an even more efficient (non scripted loop) method.
- Scripts can also copy and delete files. [
/copy
|/remove
]
Binary variables
- Contain unlimited (8192 bytes prior to mIRC 6.1) raw data
- Globally accessible via commands and identifiers
- Automatically unset when script returns control to mIRC (and not to another part of a script)
- Prefixed with
&
(eg.&Variable
) - Cannot be accessed other than by
/bread
and/bwrite
, so these variables cannot be passed onto other parts of the script
Hash tables
- May contain unlimited binary data or up to 4,150 (950 prior to mIRC 6.32) bytes of plain text. This limit is imposed by mIRC's scripting parser's own line length limitation (unless assigning a binary variable)
- Globally accessible via commands and identifiers
- Automatically unset when exiting mIRC as they are only stored in memory
- Can be saved for later use
- Not prefixed
- Faster than accessing from a file, as hash tables are stored in memory rather than the hard disk
- Size limited only by the computer's memory limits.
- Allows any bucket size to be used
Global variables
- May contain up to 4,150 (950 prior to mIRC 6.32) bytes of data including its name (however due to line-length limitations in mIRC's scripting parser, a maximum of 4,146 bytes can be assigned explicitly using /set or /var — this number decreasing as the variable's name grows longer)
- Cannot store NUL (ASCII 0) or trailing spaces
- Globally accessible
- Do not automatically unset unless a switch is used (stored automatically in a mIRC initialization file)
- Prefixed with
%
(eg.%Variable
) - Created using the
set
command orvar -g
or%Variable = value
notation
Local variables
- May contain up to 4,150 (950 prior to mIRC 6.32) bytes of data including the variable name (however due to line-length limitations in mIRC's scripting parser, a maximum of 4,146 bytes can be assigned explicitly using the /set or /var commands — this number decreasing as the variable's name grows longer)
- Can store NUL (ASCII 0) or trailing spaces
- Are destroyed when the triggered alias or event ends
- Prefixed with
%
(eg.%Variable
) - Created using the
var
command.var
is merely an internal alias forset -l
butvar
poses the means to declare multiple local variables on a single line (e.g.var %a = 1, %b, %c = 2
)
Limitations
- Scripting parser only supports a maximum of 4,150 (950 prior to mIRC 6.32) characters per line (not including newlines or indentation).
- Strings are not syntactically enclosed, creating ambiguities in code where characters meant as literal strings are treated as part of the language's syntaxSyntaxIn linguistics, syntax is the study of the principles and rules for constructing phrases and sentences in natural languages....
. - Each line of code is broken down into a set of space-delimited tokens. As mIRC's parser does not support null tokens and the language doesn't provide a syntax to clearly differentiate literal strings from code; Prior to mIRC version 6.2 it was impossible to pass multiple consecutive spaces to any command or alias. However, this was fixed with the introduction of the returnex command which allows the preservation of spaces.
Code examples
The code below is in the remote scripts format. If placed into an alias file, the command names should not be preceded by the word "alias
". Test Comments include the common /* comment */
and ;comment
.Here is an example of a Hello World alias:
Counting to 10:
A remote script event handler:
A remote script to automatically respond to certain text
Here is an example of picture windows:
External links
- Official mIRC website
- mIRC scripting links
- mircscripts.org
- mIRC Online Manual — documentation in single-page HTML format
- script.quakenet.org/wiki