mIRC scripting language

mIRC Scripting Language
Paradigm Event-driven programming, Procedural programming
Designed by Khaled Mardam-Bey
Developer Khaled Mardam-Bey
First appeared 1995 (1995)
Typing discipline Dynamic typing
OS Microsoft Windows
License Proprietary software
Filename extensions .mrc, .ini
Website http://mirc.com
Major implementations
mIRC
mIRC scripts editor (built-in)

The mIRC scripting language, often unofficially abbreviated to "mSL", is the scripting language embedded in mIRC, an IRC client for Windows.

Primary uses

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.)

File handling

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.

Binary variables

Hash tables

Global variables

Local variables

Limitations

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:

;Defines the alias 'hello' in the remote script

;Note: if this is placed in an alias script,
;the 'alias' part must be removed (result: hello {)
;Usage: /hello

alias hello {

  ;Displays(/echo) 'Hello World!' into the active window(-a)
  echo -a Hello World!

}

A remote script to automatically respond to certain text

;Placed in a remote script

;When a user types Hello! in a channel,
;you answer back: Hello, [nickname]!

on *:TEXT:Hello!:#:{ msg $chan Hello, $nick $+ ! }

;When a user types Hello! in a private message,
;you answer back: Hello, [nickname]!

on *:TEXT:Hello!:?: { msg $nick Hello, $nick $+ ! }

;Here is a script which automatically gives voice to a user
;who joins a particular channel (The Bot or user should have HOP)

on *:JOIN:#?: { mode $chan +v $nick }

;A bad word script

on *:Text:die*:#: { .mode $chan +b $nick | kick $chan $nick Dont say that again }

See also

References

Wikibooks has a book on the topic of: mIRC Scripting
This article is issued from Wikipedia - version of the 11/27/2016. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.