MIRC SCRIPTING LANGUAGE


mIRC scripts editor (built-in)

The 'mIRC scripting language' is the scripting language embedded in mIRC, a popular IRC client for Windows.

Contents
Primary uses
Other uses
Script storage
Language features
File handling
Binary variables
Hash tables
Global variables
Local variables
Limitations
Code examples
See also
External links

Primary uses



Bots 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 identifying as the owner of a nickname)

Other uses



MP3 players

mIRC games

Script storage


Scripts are stored as either plain text files, usually with a .mrc file extension, or as INI files.
Multiple script files can be loaded at one time.

Language features



★ Built-in functions are termed 'commands', or 'identifiers' if they return a value.

★ Custom text-entered functions are called 'aliases'. Aliases that return a value are known as 'custom identifiers'. Aliases are called from the command line or other parts of a script.

★ 'Popups' are scripted context menu items. Popups are called when they are selected by the user.

★ Remotes are event-handling scripts. Remotes are called when the event they handle occurs.

★ All variables are dynamically typed.

★ mIRC scripts make use of sigils. 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 | 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)
Hash tables


★ May contain unlimited binary data or up to 941 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

★ Not prefixed
Global variables


★ May contain up to 946 bytes of data (however due to line-length limitations in mIRC's scripting parser, a maximum of 943 bytes can be assigned by conventional means - this number decreasing as the variable's name grows longer)

★ Cannot store NUL (ASCII 0) or trailing spaces

★ Globally accessible

★ Do not automatically unset (stored automatically in a mIRC initialization file)

★ Prefixed with % (eg. %Variable)

★ Created using the set command or %Variable = value notation
Local variables


★ May contain up to 946 bytes of data (however due to line-length limitations in mIRC's scripting parser, a maximum of 943 bytes can be assigned by conventional means - this number decreasing as the variable's name grows longer)

★ Cannot store NUL (ASCII 0) or trailing spaces

★ Accessible only within the scope that created them

★ Prefixed with % (eg. %Variable)

★ Created using the var command. var is merely an internal alias for set -l but var poses the means to declare multiple local variables on a single line (e.g. var %a = 1,%b,%c = 2)

Limitations



★ mIRC's scripting parser only supports a maximum of 947 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 syntax.

★ 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, it is impossible to pass multiple consecutive spaces to any command or alias. However, there is a DLL called spaces.dll that allows the use of multiple 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".
Here is an example of a Hello World alias:

alias hello {
echo -a Hello World!
}


Counting to 10:

alias ten {
var %i = 1
while (%i <= 10) {
echo -a %i
inc %i
}
}


A remote script event handler:

on
★ :JOIN:#IRChelp:{
msg $chan Hello $nick
}


Here is an example of picture windows:

alias cir {
var %x = 0
window -ek0p @cir
while (%x < 360) {
inc %x
drawdot @cir 4 2 $calc(($cos(%x)
★ 50)+200) $calc(($sin(%x)
★ 50)+200)
}
}


See also



Internet Relay Chat

mIRC

Z-Net

OmenServe

mIRC game

External links



Links to mIRC scripting websites

mIRC Homepage

mIRC Online Manual — documentation in single-page HTML format

This article provided by Wikipedia. To edit the contents of this article, click here for original source.

psst.. try this: add to faves